akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int dp[100005];
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N;
    cin >> N;
    REP(i, N + 5) { dp[i] = INF; }
    dp[0] = 0;
    REP(i, N) {
        int now = 1;
        while (i + now <= N) {
            chmin(dp[i + now], dp[i] + 1);
            now *= 6;
        }
        now = 1;
        while (i + now <= N) {
            chmin(dp[i + now], dp[i] + 1);
            now *= 9;
        }
    }
    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  string S;
  cin >> N >> S;
  string memo = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (S.at(i) == memo.at(j)) {
        S.at(i) = memo.at(j + N);
        break;
      }
    }
  }
  cout << S << endl;     
}

Measured memory_bytes: 3660
import math
n = int(input())
x = [0]*n
y = [0]*n
x = list(map(float,input().split()))
y = list(map(float,input().split()))
dist1 = 0
dist2 = 0
dist3 = 0
diste = 0
for i in range(n):
    dist1 += abs(x[i]-y[i])
    dist2 += abs(x[i]-y[i])**2
    dist3 += abs(x[i]-y[i])**3
    diste = max(diste,abs(x[i]-y[i]))
print(str(dist1))
print(str(dist2**(1/2)))
print(str(dist3**(1/3)))
print(str(diste))


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

int main() {
    int N, i, j, min, HP;
    cin >> N;
	vector<int> X(N + 1);
    for (i = 1; i <= N; i++){
        cin >> X.at(i);
    }

    min = 1000000;

    HP = 0;
    for (i = 1; i <= 100; i++){
        HP = 0;
        for(j = 1; j <= N; j++){
            HP += (X.at(j) - i) * (X.at(j) - i);
        }
        if (min > HP) min = HP;
    }
    cout << min << endl;
}


Measured memory_bytes: 256
S = list(input())
S = S[::-1]
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
mod = 10**9+7
mul = 1
for i in range(len(S)):
  if S[i] == '?':
    for j in range(10):
      for k in range(13):
        dp[i+1][(j*mul+k)%13] += dp[i][k] % mod
  else:
    s = int(S[i])
    for k in range(13):
      dp[i+1][(s*mul+k)%13] += dp[i][k] % mod

  mul = (mul * 10) % 13
    
print(dp[len(S)][5]%mod)

Measured memory_bytes: 65256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int X;
    cin >> X;
    long long PA, PB;
    for(int A=-200; A<200; ++A) {
        PA = A*A;
        PA = PA*PA*A;
        for(int B=-200; B<200; ++B) {
            PB = B*B;
            PB = PB*PB*B;
            if (PA - PB == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-

n,k=map(int, input().split())
a=list(map(int, input().split()))
isUsed=[False]*n

path = [1]
#isUsed[0] = True

i = 1
while(True):
    idx = i-1
    if isUsed[idx]: #既に行ったことがある町であれば
        #print("行ったことのある町です")
        #print("i", i)
        start = path.index(i)
        break
    else:
        isUsed[idx] = True
        path.append(a[idx])
        #print(path)
        i = a[idx]


if k >= start:
    #print(start)
    #print(len(path)-1)
    num = len(path) - 1 - start
    lis_mod = path[start:start+num]

    mod = len(lis_mod)

    #print("k-start",k-start)
    tmp = (k-start)%mod
    #print("k-start % mod", tmp)
    print(lis_mod[tmp])
else:
    print(path[k])



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

int main() {
 vector<int> vec(3);
 for(int i = 0;i<3;i++){
   cin >> vec[i];
 }
  int m = max(vec[0],max(vec[1],vec[2]));
  for(int i = 0;i<3;i++){
   vec[i] = m-vec[i];
 }
   
  sort(vec.begin(), vec.end());
  
  int c = 0;
  if((vec[2]-vec[1])%2 == 0){
    c += vec[1];
    vec[2] = vec[2]-vec[1];
    vec[1] = 0;
    c += vec[2]/2;
  }
   else{
     vec[2] = vec[2]+1;
     c++;
     c += vec[1];
     vec[2] = vec[2]-vec[1];
     vec[1] = 0;
     c += vec[2]/2;
  }
  cout << c << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    map<ll, ll> mp;
    rep(i, n) {
        ++mp[i + a[i]];
    }

    ll ans = 0;
    rep(i, n) {
        ans += mp[i - a[i]];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 26552
#include <cstdio>
#include <algorithm>
#define MAX 200001
using namespace std;

int R[MAX];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &R[i]);
    }

    int diff_max = R[1] - R[0];
    int diff;
    int min_element = min(R[1], R[0]);
    for (int i = 2; i < n; i++) {
        diff = R[i] - min_element;
        if (diff > diff_max) {
            diff_max = diff;
        }
        if (R[i] < min_element) {
            min_element = R[i];
        }
    }
    printf("%d\n", diff_max);
}



Measured memory_bytes: 3540
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const int N = 105, K = 1e5 + 100, mod = 1e9 + 7;
ll dp[2][K], a[N], n, k;
int main(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= k; j++){
            dp[1][j] = dp[1][j - 1] + dp[0][j];
            if(j - a[i] - 1 >= 0){
                dp[1][j] -= dp[0][j - a[i] - 1];
                if(dp[1][j] < 0)dp[1][j] += mod;
            }
            if(dp[1][j] >= mod) dp[1][j] -= mod;
        }
        for(int j = 0; j <= k; j++){
            dp[0][j] = dp[1][j];
        }
    } 
    cout << dp[0][k] << endl;
}    

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

int main(){
  long long a,b,n;
  cin >> a;
  cin >> b;
  n = a*b;

  int temp;
  if(b < a){
    temp = b;
    b = a;
    a = temp;
  }

  int r = b % a;
  while(r > 0){
    temp = a % r;
    a = r;
    r = temp;
  }

  cout << n/a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
  return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
  template <class C>
  static char test(typename C::const_iterator*);
  template <class C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o, const C& c) {
  o << '[';
  for (auto it = c.begin(); it != c.end();)
      o << *it << (++it != c.end() ? ", " : "");
  return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
  return o << '(' << p.fi << ", " << p.se << ')';
}

void solve() {
  int x, y;
  cin >> x >> y;
  F0R (i, 100) {
    F0R (j, 100) {
      if (i + j == x && i * 2 + j * 4 == y) {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}

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

  int tt = 1;
  FOR (t, 1, tt + 1) {
      // cout << "Case #" << t << ": ";
      solve();
  }

  return 0;
}


Measured memory_bytes: 3640
N = int(input())
AList = list(map(int, input().split()))

sortList = sorted(AList)
Amax = max(sortList)
dp = [0] * (Amax+1)

for n in sortList:
  dp[n] += 1
  if dp[n] == 1:
    for j in range(n*2, Amax+1, n):
      dp[j] += 2
print(dp.count(1))

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

int inf=pow(10,9);

int main() {
  
  string s1;
  string s2;
  cin>>s1>>s2;


    int n=s1.length();
    int m=s2.length();

    int dp[n+1][m+1];

    for(int i=0;i<=n;i++){
        dp[i][0]=0;

    }
    
    for(int j=0;j<=m;j++){
        dp[0][j]=0;

    }

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

            if(s1[i-1]==s2[j-1]){
                dp[i][j]=1+dp[i-1][j-1];

            }else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);

            }
            
        }
    }


    int i=n;
    int j=m;

    string ans="";

    while(i>0 && j>0){

        if(s1[i-1]==s2[j-1]){
            ans+=s1[i-1];
            i--;
            j--;

        }else{

            if(dp[i-1][j]>dp[i][j-1]){
                i--;

            }else{
                j--;

            }

        }
    }

    reverse(ans.begin(),ans.end());

    cout<<ans;




}


Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int H, W, N;
	cin >> H >> W >> N;
	cout << divcel(N, max(H, W)) << endl;

	return 0;
}


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

using namespace std;

const int N = 3002;
string a,b, odp = "";
int dp [N][N];


int main(){
    ios_base::sync_with_stdio(0);


    cin >> a >> b;

    for (int i=1; i<=a.size(); i++){

        for (int j=1; j<=b.size(); j++){

            if (a[i-1] == b[j-1]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }


    int i=a.size(), j=b.size();

    while (i != 0 && j != 0){

        if (a[i-1]==b[j-1]){
            odp = a[i-1] + odp;
            i--;j--;
        }

        else if (dp[i-1][j] > dp[i][j-1]) i--;
        else j--;
    }

    cout << odp;

}

Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N  = sc.nextInt();
		
		int sum = f753(0, false, false, false, N);
		System.out.println(sum);
	}
	
	public static int f753(long x, boolean c7, boolean c5, boolean c3, int N) {
		int res = 0;
		
		if(x > N) {
			return res;
		}
		
		if(c7 && c5 && c3) {
			res++;
		}
		
		res += f753(x * 10 + 7, true, c5, c3, N);
		res += f753(x * 10 + 5, c7, true, c3, N);
		res += f753(x * 10 + 3, c7, c5, true, N);
		
		return res;
	}
	
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

const int mod = 1000000007; // 998244353;
struct mint {
  long long x;
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    return mint(*this) += a;
  }
  mint operator-(const mint& a) const {
    return mint(*this) -= a;
  }
  mint operator*(const mint& a) const {
    return mint(*this) *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint& a) { return *this *= a.inv(); }
  mint operator/(const mint& a) const {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

map<long long, int> mp;
void prime_factor(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if(n != 1) mp[n]++;
}

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    prime_factor(i);
  }
  mint ans=1;
  for(auto x:mp){
    ans*=x.se+1;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 764
n = int(input())
li = list(map(int,input().split()))
li = [-1] + li

dp = [-1] * (n+1)
cnt = n
tmp = 0
s = -1
#print(li)

for i in range(1,n+1):
    for j in range(0,n+1,cnt):
        if j == 0:
            continue
        if s == -1:
            s = j
        if dp[-i] == -1:
            dp[-i] = li[j]
        tmp += dp[j]
        #print(i,j,tmp,li[j])
    
    if tmp%2 != li[s]:
        tmp -= dp[s]
        dp[s] = (li[s]+1)%2
        tmp += dp[s]
        if tmp%2 != li[s]:
            print(-1)
            exit()
    cnt -= 1
    tmp = 0
    s = -1

#print(dp)
print(dp.count(1))
ans = list([i for i,x in enumerate(dp) if x == 1])
print(*ans)

Measured memory_bytes: 14508
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int h, w;
    cin >> h >> w;
    char a;
    rep(i, w + 2)
    {
        cout << "#";
    }
    cout << endl;
    rep(i, h)
    {
        cout << "#";
        rep(j, w)
        {
            cin >> a;
            cout << a;
        }
        cout << "#" << endl;
    }
    rep(i, w + 2)
    {
        cout << "#";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
set<int> base;
 
struct UnionFind {
  vector<int> data;
  UnionFind(int n):data(n, -1){}
  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    //if(data[x] < data[y]) swap(x, y);
    if(!base.count(x)) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};
 
struct edge {
  int from, to, cost;
  edge(){}
  edge(int from, int to, int cost):from(from), to(to), cost(cost){}
  bool operator < (const edge& e) const {
    return cost > e.cost;
  }
};
 
using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
 
vector<edge> es;
 
int main() {
  int n, t, k;
  int T = 0;
  while(cin >> n >> t >> k, n || t || k) {
    base.clear();
    es.clear();
    for(int i = 0; i < n-1; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      --a, --b;
      es.emplace_back(a, b, c);
    }
    UnionFind uf(n);
    for(int i = 0; i < t; i++) {
      int d; cin >> d; --d;
      base.insert(d);
    }
    vector<int> ans;
    sort(es.begin(), es.end());
      for(edge& e : es) {
    if(!uf.same(e.from, e.to)) {
      int x = uf.find(e.from), y = uf.find(e.to);
      if(base.count(x) && base.count(y)) {
        ans.push_back(e.cost);
      }
      uf.unite(x, y);
      }
    }
    sort(ans.begin(), ans.end());
    int total = 0;
    for(int i = 0; i < k; i++) total += ans[i];
    cout << "Case " << ++T << ": " << total << endl;
  }
  return 0;
}

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

using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n){
    int x;
    cin >> x;
    --x;
    a[x] = i + 1;
  }
  REP(i, n){
    printf("%d%c", a[i], i < n - 1 ? 32 : 10);
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n;
  cin>>n;
  vl a(n);
  REP(i, n) cin>>a[i];
  vc(mint) b(n);
  rREP(i, n-1) {
    b[i] = b[i+1] + a[i+1];
  }
  mint ans = 0;
  REP(i, n) {
    mint tmp = mint(a[i]) * b[i];
    ans += tmp;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6412
#include <iostream>
#include <string> 
#include <map>
using namespace std;
map<char,int> m;
int main(){
	string s;
	cin>>s;
	int cnt=0;
	for(int i=0;i<4;i++){
		if(m[s[i]]==0){
			if(cnt==2){
				cout<<"No"<<endl;
				return 0;
			}
			else{
				cnt++;
				m[s[i]]++;
			}
		}
		else if(m[s[i]]==2){
			cout<<"No"<<endl;
			return 0;
		}
		else{
			m[s[i]]++;
		}
	} 
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> Book(N, tuple<string, int, int>());
  
  for (int i = 0; i < N; i++) {
    string s;
    int a;
    cin >> s >> a;
    Book.at(i) = make_tuple(s, 100-a, i);
  }
  
  sort(Book.begin(), Book.end());
  
  for (int i = 0; i < N; i++) {
    cout << get<2>(Book.at(i)) + 1<< endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
V = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

ans = 0
for i in range(N) :
    if V[i] > C[i] :
        ans += V[i] - C[i]

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(I, A) for (int(I) = 0; (I) < (A); (I)++)
#define pb(I) push_back(I)
const int N = 10000000;

set<int> s, e;
vector<int> vx, vy, Gx[200];
int matl[1000], matr[1000];
bool vis[1000];

bool is_prime(int x) {
	if(x < 3) return false;
	for (int i = 3; i*i <= x; i++) if(x % i == 0) return false;
	return true;
}

bool dfs(int x) {
	for (int v : Gx[x]) {
		if (!vis[v]) {
			vis[v] = true;
			if (matl[v] == -1 || dfs(matl[v])) {
				matl[v] = x;
				matr[x] = v;
				return true;
			}
		}
	}
	return false;
}

int domatch() {
	memset(matl, -1, sizeof(matl));
	memset(matr, -1, sizeof(matr));
	int cnt = 0;
	REP(i, vx.size()) {
		if (matr[i] != -1)
			continue;
		memset(vis, 0, sizeof(vis));
		cnt += dfs(i);
	}
	return cnt;
}

int main() {
	int n, x;
	scanf("%d", &n);
	REP(i, n) {
		scanf("%d", &x);
		s.insert(x);
	}
	for (int u : s) {
		if (!s.count(u - 1))
			e.insert(u);
		if (!s.count(u + 1))
			e.insert(u + 1);
	}
	for (int u : e)
		if (u & 1)
			vx.pb(u);
		else
			vy.pb(u);
	REP(i, vx.size())
	REP(j, vy.size())
	if (is_prime(abs(vx[i] - vy[j])))
		Gx[i].pb(j);
	int t = domatch();
	int l1 = vx.size() - t, l2 = vy.size() - t;
	int res = t;
	res += l1 / 2 * 2;
	res += l2 / 2 * 2;
	if (l1 % 2 == 1 && l2 % 2 == 1)
		res += 3;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
/*
2432902008176640000
121645100408832000
6402373705728000
355687428096000
20922789888000
  */
long long fact(long long n){ return n>0 ? fact(n-1)*n : 1LL; }
int main(){
  puts("2432902008176640000"); return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
 
int main() {
  ll a,b,c;
  ci(a>>b>>c);
  ll d=b+c;
  a-=c;
  for(i,1,pow(10,5)){
    a-=d;
    if(a<d){
      co(i);
      break;
    }
  }
}

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

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

#define MOD 1000000007
#define MAX 2000

int main(){
    ULL *cmb[MAX+1];
    int s;
    int div;
    int mod;
    int i,j;
    ULL count;
    cin >> s;
    
   
    for(i=0;i<=MAX;i++){
        cmb[i] = new ULL[MAX+1];
        for(j=0;j<=i;j++){
            if(i == 0 || j== 0){
                cmb[i][j] = 1;
            }else{
                cmb[i][j] = cmb[i-1][j-1] + cmb[i-1][j];
            }
            //cout << cmb[i][j] << " ";
            cmb[i][j] %= MOD;
        }
        cout << endl;
    }
     div = 1;
    count = 0;
    while( s - div * 3 >= 0){
        mod = s - div * 3;
        //cout << div << ":" << mod << ":" << cmb[mod+div-1][div-1] << endl;
        count += cmb[mod + div-1][div-1];
        count %= MOD;
        div++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 26200
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int h,n;
    cin >> h >> n;
    ll sum=0;
    REP(i,n){
        int a;
        cin >> a;
        sum+=a;
    }
    string s="Yes";
    if(sum<h) s="No";
    cout << s;

    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  
  long long a[N];
  long long a_max = 0;
  int a_max_place = -1;
  long long a_min = 0;
  int a_min_place = -1;
  for(int i = 0; i < N; i++){
    scanf("%lld", a + i);
    
    if(a[i] >= a_max){
      a_max = a[i];
      a_max_place = i;
    }
    if(a[i] <= a_min){
      a_min = a[i];
      a_min_place = i;
    }
  }
  
  int m = 0;
  int a_abs_place;
  if(a_max > -a_min) a_abs_place = a_max_place;
  else a_abs_place = a_min_place;
  if(a_max_place != -1 && a_min_place != -1){
    printf("%d\n", 2 * (N - 1));
    for(int i = 0; i < N; i++){
      if(i != a_abs_place) printf("%d %d\n", a_abs_place + 1, i + 1);
    }
  }else printf("%d\n", N - 1);
  
  if(a_max > -a_min){
    for(int i = 1; i < N; i++){
      printf("%d %d\n", i, i + 1);
    }
  }else{
    for(int i = 1; i < N; i++){
      printf("%d %d\n", N - i + 1, N - i);
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int i,j;
	long long int a,s,d=0,f,g,h;
	scanf("%lld %lld",&a,&s);
	if(s>=a*2){
		s=s-a*2;
		d=a;
	}
	else{
		a=s/2;
		s=s%2;
		d+=a;
	}
	if(s>=4){
		d+=s/4;	
	}

	printf("%lld\n",d);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define N 55
using namespace std;
typedef vector<vector<bool> > V;
typedef pair<int,int> P;
typedef pair<P,P> PP;
string mp[N];
vector<PP> A;
int h,w;

bool compare(PP &a,PP &b){
  int w1 = a.second.first - a.first.first+1;
  int h1 = a.second.second - a.first.second+1; 
  int w2 = b.second.first - b.first.first+1;
  int h2 = b.second.second -b.first.second+1;
  return h1*w1 < h2*w2;
}

map<P,V> v;
void visit(int x,int y){
  if(v.count(P(x,y)))return;

  if(x<0||y<0||x>=w||y>=h){
    v[P(x,y)] = V(N,vector<bool>(N,1));
    return;
  }
  V &D = v[P(x,y)] =V(N,vector<bool>(N,0));
  D[y][x] = 1;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) {
      if(mp[i][j] == '#')continue;
      if(i)D[i][j] = D[i][j]|D[i-1][j];
      if(j)D[i][j] = D[i][j]|D[i][j-1];
    }
}

void pushA(int x,int y){
  visit(x,y);
  V &D = v[P(x,y)];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(!D[i][j]||islower(mp[i][j])||tolower(mp[i][j])!=mp[y][x])continue;
      A.push_back(PP(P(x,y),P(j,i)));
    }
}

void mkA(){
  A.clear();
  v.clear();
  visit(0,0);
  V &D = v[P(0,0)];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(D[i][j]&&islower(mp[i][j]))pushA(j,i);
  
  sort(A.begin(),A.end(),compare);
}

bool check(PP a,PP b){
  int x1=a.first.first,y1=a.first.second;
  int X1=a.second.first,Y1=a.second.second;
  int x2=b.first.first,y2=b.first.second;
  int X2=b.second.first,Y2=b.second.second;
  if(a.first==b.first||a.second == b.second)return 0;
  
  visit(x1,y1),visit(X2,Y2);
  V &A = v[P(x1,y1)],&B = v[P(X2,Y2)]; 
  if(!A[y2][x2]||(X1<w&&X2<h&&!B[Y1][X1]||!B[h-1][w-1]))return 0;
  return x1<=x2&&X2<=X1&&y1<=y2&&Y2<=Y1;
}


map<PP,int> mem[1000];
int dfs(int idx,PP sta){  
  if(idx == -1) return 0;
  if(mem[idx].count(sta))return mem[idx][sta];
  int res = dfs(idx-1,sta);
  if(check(sta,A[idx])){
    int a = dfs(idx-1,PP(sta.first,A[idx].first));
    int b = dfs(idx-1,A[idx]);
    int c = dfs(idx-1,PP(A[idx].second,sta.second));
    res = max(res,a+b+c+1);
  }
  return mem[idx][sta] = res;
}

int main(){
  while(1){
    cin>>h>>w;
    if(!h&&!w)break;
    for(int i=0;i<h;i++)cin>>mp[i];
    for(int i=0;i<1000;i++)mem[i].clear();
    mkA();
    visit(0,0);
    if(!v[P(0,0)][h-1][w-1]) cout<<-1<<endl;
    else cout<<dfs(A.size()-1,PP(P(-1,-1),P(w,h)))<<endl;
    
  }
}

Measured memory_bytes: 145248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll n, x, cur, l1, l2;
vector <ll> a;

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x;
		a.pb(x);
	}
	sort(a.rbegin(),a.rend());
	for(int i = 0; i < n; i++){
		if(a[i]==cur){
			if(l1==0){
				l1=cur;
				cur=0;
			}
			else{
				l2=cur;
				cout << l1*l2 << endl;
				return 0;
			}
		}
		else{
			cur=a[i];
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 1400
require "prime"

class Integer
  def divisors
    prime_division.inject([1]) do |ary, (p, e)|
      (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
    end.sort
  end
  def kawara_wari(k); t=self; while t % k == 0 do t/=k end; t end 
end

n = gets.to_i

ans = (n-1).divisors.size - 1

n.divisors.each do |d|
  next if d == 1
  ans += 1 if n.kawara_wari(d) % d == 1
end

puts ans

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int d;
  cin >> d;
  vector<int> c(26);
  int i,j,k;
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(d,vector<int>(26));
  rep(i,d)rep(j,26) cin >> s[i][j]; 
  vector<int> t(d);
  /*rep(i,d)
  {
    int ind = -1;
    int val = -1;
    rep(j,26)
    {
      if(s[i][j] > val)
      {
        val = s[i][j];
        ind = j;
      }
    }
    t[i] = ind;
  }*/
  vector<int> las(26,0);
  vector<int> rowans(26,0);
  int sums = 0;
  int kans = 0;
  rep(i,d)
  {
    int vind = -1;
    int vval = -100000000;
    rep(j,26)
    {
      vector<int> klas(26);
      klas = las;
      klas[j] = i+1;
      sums += s[i][j];
      vector<int> krowans(26);
      krowans = rowans;
      rep(k,26)
      {
        krowans[k] += c[k]*(i+1-klas[k]);
      }
      int ks = sums;
      rep(k,26) ks -= krowans[k];
      if(vval < ks)
      {
        vval = ks;
        vind = j;
      }
      sums -= s[i][j];
    }
    t[i] = vind;
    las[t[i]] = i+1;
    sums += s[i][t[i]];
    kans += s[i][t[i]];
    rep(j,26)
    {
      kans -= c[j]*(i+1-las[j]);
      rowans[j] += c[j]*(i+1-las[j]);
    }
  }
  int m = 1000000;
  //double tmp = 100.0;
  //double alpha = 0.9999;
  //int inds = 0;
  rep(i,m)
  {
    int tans = 0;
    int tod,q;
    tod = rand()%d;
    q = rand()%26;
    int bq = t[tod];
    sums -= s[tod][bq];
    sums += s[tod][q];
    int browq = rowans[bq];
    int rowq = rowans[q];
    t[tod] = q; //change
    rowans[q] = 0;
    rowans[bq] = 0;
    rep(j,26)
    {
      las[j] = 0;
    }
    rep(j,d)
    {
      las[t[j]] = j+1;
      rowans[bq] += c[bq]*(j+1-las[bq]);
      rowans[q] += c[q]*(j+1-las[q]);
    }
    tans = sums;
    rep(j,26) tans -= rowans[j];
    //double prob = ((double)rand())/32767.0;
    int dis = kans-tans;
    if(tans >= kans)
    {
      kans = tans;
    }
    else
    {
      rowans[bq] = browq;
      rowans[q] = rowq;
      t[tod] = bq;
    }
    /*else if(prob <= exp(-(double)dis/(double)tmp))
    {
      kans = tans;
    }*/
    
    //tmp *= alpha;
    //cout << tmp << endl;
    //if(i%1000 == 0)cout << kans << endl;
  }
  rep(i,d)
  {
    cout << t[i]+1 << "\n";
  }
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 2019;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcount
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
const int siz = 2*(1e5 + 1);
const int logi = 21;
const double epsilon = 1e-6;
int prime[siz];
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}


signed main()
{
	
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		int n = s.length();

		int pre[n];
		for(int i = 0 ; i < n ; i++)
		{
			int d = s[i]-'0';

			int val = be(10,n-i-1,mod);
			d = (val*d)%mod;

			pre[i] = d;
		}

		map<int,int> mp;
		mp[pre[0]]++;
		for(int i = 1 ; i < n ; i++)
		{
			pre[i] = (pre[i-1] + pre[i])%mod;
			mp[pre[i]]++;

		}

		int sum = mp[0];

		for(int i = 1 ; i < n ; i++)
		{
			mp[pre[i-1]]--;
			sum += mp[pre[i-1]];
		}

		cout<<sum<<"\n";
	}
}



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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

signed main(){
    i64 h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<i64> dx = {1, 0, -1, 0, 1, 1, -1, -1, 0};
    vector<i64> dy = {0, 1, 0, -1, 1, -1, 1, -1, 0};
    vector<string> s(h);
    for(auto& x : s)
        cin >> x;
    i64 st_x, st_y, en_x, en_y;
    for(i64 i = 0; i < h; ++i)
        for(i64 j = 0; j < w; ++j){
            if(s[i][j] == 's'){
                st_x = i;
                st_y = j;
            }
            if(s[i][j] == 'g'){
                en_x = i;
                en_y = j;
            }
        }
    priority_queue<tuple<i64,i64,i64>, vector<tuple<i64,i64,i64>>, greater<tuple<i64,i64,i64>>> que;
    vector<vector<i64>> range(h, vector<i64>(w, INF));
    range[st_x][st_y] = 0;
    que.emplace(0, st_x, st_y);
    while(!que.empty()){
       i64 dist, x, y;
       tie(dist, x, y) = que.top();
       que.pop();
       bool fl = true;
       for(i64 i = 0; i < 9; ++i){
           i64 xx = x + dx[i];
           i64 yy = y + dy[i];
           if(xx >= 0 && xx < h && yy >= 0 && yy < w && s[xx][yy] == '*')
               fl = false;
       }
       for(i64 i = 0; i < (fl ? 8 : 4); ++i){
           i64 xx = x + dx[i];
           i64 yy = y + dy[i];
           if(!(xx >= 0 && xx < h && yy >= 0 && yy < w))
               continue;
           // 移動にかかるcost
           i64 cost = range[x][y] + a * (i / 4 + 1);
           // ほげ
           if(!fl && s[xx][yy] == '#')
               continue;
           if(s[xx][yy] == '#' || i >= 4)
               cost += b;
           if(range[xx][yy] > cost){
               range[xx][yy] = cost;
               que.emplace(cost, xx, yy);
           }
       }
    }
    if(range[en_x][en_y] >= 1e15)
        cout << "INF" << endl;
    else
        cout << range[en_x][en_y] << endl;
}



Measured memory_bytes: 11808
#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);

    int possible = false;

    if(n >= 21)
    {
        possible = true;
    }
    else
    {
        for(int i = 0; 4*i <= n; i++)
        {
            if( (n - 4*i)%7 == 0)
            {
                possible = true;
                break;
            }
        }
    }

    printf(possible ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 128
//B Checkpoints.cpp
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef unsigned long long ull;

int main(){
    int n , m;
    cin >> n >> m;
    int a[n],b[n];
    int c[m],d[m];
    for(int i=0;i<n;++i) cin >> a[i] >> b[i];
    for(int i=0;i<m;++i) cin >> c[i] >> d[i];
    
    for(int i=0;i<n;++i){
        int dis;int prev=INF;int ans;
        for(int j=0;j<m;++j){
            dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(dis<prev) {ans = j + 1; prev=dis;}
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long double N, K;
    cin >> N >> K;

    long double ex = 0;
    FOR(sai, 1, N + 1) {
        if (sai >= K) {
            ex++;
        } else {
            ll n_trial = ceil(log2(K / sai));
            // if (n_trial < 1) n_trial = 1;
            ex += pow(2, -n_trial);
            debug(sai, n_trial);
        }
    }
    long double ans = ex / N;
    cout << setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    ld r; cin >> r;
    cout << fixed << setprecision(15) << PI*r*r  << " " << 2*PI*r << endl;

    
}


Measured memory_bytes: 3240
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#define inf 20021225
#define ll long long
#define mxn 2010
#define mp make_pair
#define fs first
#define se second
#define pa pair<int,int>
using namespace std;
 
struct edge{int to,lt;}e[mxn<<1];
int f[mxn][mxn],in[mxn],cnt,d[mxn];
int n,k;bool del[mxn];
set<pa> st;
void add(int x,int y)
{
	e[++cnt].to=y;e[cnt].lt=in[x];in[x]=cnt;
	e[++cnt].to=x;e[cnt].lt=in[y];in[y]=cnt;
}
 
void dfs(int x,int fa,int rt)
{
	for(int i=in[x];i;i=e[i].lt)
	{
		int y=e[i].to;if(y==fa) 	continue;
		f[rt][y]=f[rt][x]+1; dfs(y,x,rt);
	}
}
 
void getdis()
{
	for(int i=1;i<=n;i++)	dfs(i,i,i);
}
 
void work()
{
	int ans=0,x,tmp;	getdis();
	for(int i=1;i<=n;i++)
	{
		tmp=0; if(d[i]!=1)	continue;
		for(int j=1;j<=n;j++)
			if(f[i][j]>k)	tmp++;
		st.insert(mp(tmp,i));
	}
	while(!st.empty())
	{
		set<pa>::iterator it=--st.end(); pa mx=*it;
		if(mx.fs<=0)	break;
		del[mx.se]=1; st.erase(it);	x=mx.se;
		for(it=st.begin();it!=st.end();it++)
		{
			pa cur=*it; int y=cur.se;
			if(f[x][y]>k)
				st.erase(it),st.insert(mp(cur.fs-1,y));
		}
		for(int i=in[x];i;i=e[i].lt)
		{
			int y=e[i].to; d[y]--;// printf("%d %d\n",y,d[y]);
			if(d[y]==1)
			{
				tmp=0;
				for(int j=1;j<=n;j++)
					if(!del[j]&&f[y][j]>k)	tmp++;
				st.insert(mp(tmp,y));
			}
		}
		ans++;
	}
	printf("%d\n",ans);
}
 
int main()
{
	int x,y;
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++)	scanf("%d%d",&x,&y),add(x,y),d[x]++,d[y]++;
	work();
	return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=1e5;
ll N,M,a[MAX_N],g;
vector<ll> vec[MAX_N],G[MAX_N];
bool used[MAX_N];
void dfs(ll v,ll g){
	used[v]=true;
	vec[g].push_back(a[v]);
	for(auto e:G[v]){
		if(!used[e]){
			dfs(e,g);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M;
	REP(i,N)cin>>a[i];
	REP(i,M){
		ll x,y;
		cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	g=0;
	REP(v,N){
		if(!used[v]){
			dfs(v,g++);
		}
	}
	if(N>=2*(g-1)){
		if(g==1){
			cout<<0<<endl;
		}else{
			ll ans=0;
			vector<ll> vs;
			REP(i,g){
				sort(vec[i].begin(),vec[i].end());
				ans+=vec[i][0];
				REP(j,vec[i].size()-1){
					vs.push_back(vec[i][j+1]);
				}
			}
			sort(vs.begin(),vs.end());
			REP(i,g-2){
				ans+=vs[i];
			}
			cout<<ans<<endl;
		}
	}else{
		cout<<"Impossible"<<endl;
	}
}

Measured memory_bytes: 12408
N, A, B = map(int, input().split())
MOD = 998244353

if B == 0:
    print(1)
    exit()

f = 1
F = [1] * (N + 1)
for i in range(1, N + 1):
    F[i] = f = f * i % MOD

FI = [1] * (N + 1)
FI[N] = fi = pow(f, MOD - 2, MOD)
for i in range(N, 1, -1):
    FI[i - 1] = fi = fi * i % MOD

z = 0
for k in range(min(A + 1, N - B) if N - B - A else A + 1):
    x = (B - k) * F[B + k - 1] * FI[B] * FI[k] % MOD
    y = F[N + A - B - 2 * k - 1] * FI[N - B - k - 1] * FI[A - k] % MOD
    z = (z + x * y) % MOD

print(z)

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

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

  vector<vector<int>> v(n);
  for(int i=0; i<n; ++i) v[i].resize(n);

  for(int i=0; i<n; ++i){
    int u, k; cin >> u >> k;
    while(k--){
      int x; cin >> x;
      v[u-1][x-1] = 1;
    }
  }

  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      cout << (j != 0 ? " " : "") << v[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3124
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        s: [chars;n]
    }

    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;

    //println!("{:?}", s);
    for i in 0..n {
        match s[i][0] {
            'A' => {
                ac += 1;
            }
            'W' => {
                wa += 1;
            }
            'T' => {
                tle += 1;
            }
            'R' => {
                re += 1;
            }
            _ => {}
        }
    }

    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


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

long long GA[305][305],GA_num[305][305];
long long inf=1e15+7;

struct node
{
	int sta,des;
}question[100005];

int main()
{
	long long n,m,l,q;
	cin>>n>>m>>l;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (i!=j)
			{
				GA[i][j]=inf;
			    GA_num[i][j]=inf;
			}
			else
			{
				GA[i][j]=0;
			    GA_num[i][j]=0;
			}
		}
	}
	for (int i=1;i<=m;i++)
	{
		long long a,b,len;
		cin>>a>>b>>len;
		GA[a][b]=len;
		GA[b][a]=len;		
	}
	cin>>q;
	for (int i=1;i<=q;i++)  cin>>question[i].sta>>question[i].des;
	for (int k=1;k<=n;k++)
	{
		for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=n;j++)
			{
				if (GA[i][k]+GA[k][j]<GA[i][j]&&GA[i][k]+GA[k][j]>=0)  
				{
					GA[i][j]=GA[i][k]+GA[k][j];
					GA[j][i]=GA[i][k]+GA[j][k];
				}
			}
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (GA[i][j]<=l&&i!=j)
			{
				GA_num[i][j]=1;
				GA_num[j][i]=1;
			}
		}
	}
	for (int k=1;k<=n;k++)
	{
        for (int i=1;i<=n;i++)
        {
        	for (int j=1;j<=n;j++)
                GA_num[i][j]=min(GA_num[i][j],GA_num[i][k]+GA_num[k][j]);	
		}
    }
	for (int i=1;i<=q;i++)
	{
		long long num=GA_num[question[i].sta][question[i].des];
		if (num>1e9)  cout<<-1<<endl;
		else cout<<num-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 2688
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll h,w;
    cin>>h>>w;
    ll ans=0;
    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            ll a;
            cin>>a;
            ans+=(i+1)*(h-i)*(t+1)*(w-t)*a;
        }
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 3108