malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const double PI = 3.1415926535897932384626433832795;   using namespace std;   long long mod = 1e9 + 7;   bool visited[3005];   vector<vector<int> > G;   bool cycle[3005];   int dp[3005], P[3005];   void dfs(int u, int v) {     visited[u] = true;     int sz = G[u].size();     for (int i = 0; i < sz; ++i) {       if (v == G[u][i]) continue;       if (visited[G[u][i]] && !cycle[G[u][i]]) {         cycle[G[u][i]] = true;         for (int j = u; j != G[u][i]; j = P[j]) cycle[j] = true;         break;       }       if (visited[G[u][i]]) continue;       P[G[u][i]] = u;       dfs(G[u][i], u);     }   }   void dfs2(int u, int v, int len) {     dp[u] = len;     int sz = G[u].size();     for (int i = 0; i < sz; ++i) {       if (cycle[G[u][i]] || v == G[u][i]) continue;       dfs2(G[u][i], u, len + 1);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.precision(12);     cout << fixed;     int N, a, b;     cin >> N;     G.resize(N + 1);     for (int i = 0; i < N; ++i) {       cin >> a >> b;       G[a].push_back(b);       G[b].push_back(a);     }     P[1] = 0;     dfs(1, 0);     for (int i = 1; i <= N; ++i)       if (cycle[i]) dfs2(i, 0, 0);     for (int i = 1; i <= N; ++i) cout << dp[i] <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[55];   char s[1005][55];   bool can[1005];   int have[30];   int tmp[30];   int pos[55], tot;   int len, n, ans, rest;   set<char> se;   int main() {     scanf( %d , &len);     scanf( %s , a + 1);     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1);     for (int i = 1; i <= len; i++)       if (a[i] !=  * ) se.insert(a[i]);     for (int i = 1; i <= len; i++)       if (a[i] ==  * ) pos[++tot] = i;     for (int i = 1; i <= n; i++) {       can[i] = 1;       for (int j = 1; j <= tot; j++)         if (se.find(s[i][pos[j]]) != se.end()) {           can[i] = 0;           break;         }       for (int j = 1; j <= len; j++)         if (a[j] !=  *  && a[j] != s[i][j]) {           can[i] = 0;           break;         }       if (can[i]) rest++;     }     for (int i = 1; i <= 26; i++)       if (se.find( a  + i - 1) == se.end()) {         for (int j = 1; j <= n; j++)           if (can[j])             for (int k = 1; k <= tot; k++)               if (s[j][pos[k]] ==  a  + i - 1) {                 have[i]++;                 break;               }       }     for (int i = 1; i <= 26; i++)       if (se.find( a  + i - 1) == se.end() && have[i] == rest) ans++;     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 987654321;   const long long int INF = 123456789987654321;   FILE *fin, *fout;   int N, M;   vector<vector<int> > V;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int main() {     scanf( %d %d , &N, &M);     V = vector<vector<int> >(N, vector<int>(M));     int mx = 0;     for (int i = 0; i < N; i++) {       for (int j = 0; j < M; j++) {         scanf( %d , &V[i][j]);         mx = max(mx, V[i][j]);       }     }     int g = 0;     for (int i = 0; i < N - 1; i++) {       vector<int> D;       for (int j = 0; j < M; j++) {         D.push_back(V[i + 1][j] - V[i][j]);       }       for (int j = 0; j < (int)D.size() - 1; j++) {         g = gcd(g, abs(D[j + 1] - D[j]));       }     }     for (int i = 0; i < M - 1; i++) {       vector<int> D;       for (int j = 0; j < N; j++) {         D.push_back(V[j][i + 1] - V[j][i]);       }       for (int j = 0; j < (int)D.size() - 1; j++) {         g = gcd(g, abs(D[j + 1] - D[j]));       }     }     if (g == 0) g = 1000000007;     if (g <= mx) {       printf( NO );       return 0;     }     vector<int> a(N), b(M);     a[0] = 0, b[0] = V[0][0];     for (int i = 1; i < M; i++) {       b[i] =           ((long long int)V[0][i] - (long long int)a[0] + (long long int)g) % g;     }     for (int i = 1; i < N; i++) {       a[i] =           ((long long int)V[i][0] - (long long int)b[0] + (long long int)g) % g;     }     printf( YES n%d n , g);     for (int i = 0; i < N; i++) printf( %d  , a[i]);     printf(  n );     for (int i = 0; i < M; i++) printf( %d  , b[i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     cin >> a >> b;     while (a > 0 && b > 0) {       if (a >= 2 * b) {         a = a - (a / (2 * b)) * (2 * b);       } else if (b >= 2 * a) {         b = b - (b / (2 * a)) * (2 * a);       } else {         break;       }     }     cout << a <<     << b;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int a[N], n, ans[N], b[N];   int main() {     scanf( %d , &n);     if (n == 1) {       printf( 1 n );       return 0;     }     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i++) {       b[0] = 0;       int to = (int)sqrt((double)a[i]), k = 0;       for (int j = 1; j <= to; j++)         if (a[i] % j == 0) {           if (j > 1) b[++b[0]] = j, k = max(k, ans[j]);           if (j * j != a[i]) b[++b[0]] = a[i] / j, k = max(k, ans[a[i] / j]);         }       for (int j = 1; j <= b[0]; j++) ans[b[j]] = max(ans[b[j]], k + 1);     }     for (int i = 1; i <= (int)1e5; i++) ans[0] = max(ans[0], ans[i]);     printf( %d n , ans[0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2;     cin >> s1 >> s2;     int flag = 0;     for (int i = 0, j = s2.length() - 1; i < s1.length(), j >= 0; i++, j--) {       if (s1[i] == s2[j]) {         flag++;       }     }     if (flag == s1.length())       cout <<  YES  << endl;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 5, MOD = 1e9 + 7;   bool c[11];   int main() {     int n, k;     scanf( %d %d , &n, &k);     long long ans[n];     pair<int, pair<int, int>> a[n];     priority_queue<int> pq;     for (int i = 0; i < n; i++) {       scanf( %d , &a[i].first);     }     for (int i = 0; i < n; i++) {       scanf( %d , &a[i].second.first);       a[i].second.second = i;       ans[i] = a[i].second.first;     }     if (!k) {       for (int i = 0; i < n; i++) {         printf( %lld  , ans[i]);       }       return 0;     }     sort(a, a + n);     long long sum = a[0].second.first;     pq.push(-a[0].second.first);     for (int i = 1; i < n; i++) {       ans[a[i].second.second] += sum;       if (pq.size() == k) {         if (abs(pq.top()) < a[i].second.first) {           sum -= (abs(pq.top()));           pq.pop();           pq.push(-a[i].second.first);           sum += a[i].second.first;         }       } else {         pq.push(-a[i].second.first);         sum += a[i].second.first;       }     }     for (int i = 0; i < n; i++) {       printf( %lld  , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[1001], k;   int main() {     scanf( %d%d , &n, &k);     n = 2 * n + 1;     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 2; i < n; i += 2)       if (k && a[i - 1] + 1 < a[i] && a[i] > a[i + 1] + 1) {         a[i]--;         k--;       }     for (int i = 1; i <= n; ++i) printf( %d  , a[i]);   }
#include <bits/stdc++.h>   using namespace std;   void File() {     freopen( output.txt ,  w , stdout);     freopen( input.txt ,  r , stdin);   }   void yAsEr_HaFiz() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   int const N = 2e5 + 9, MOD = 1e9 + 7, oo = 1e9 + 7;   long long n, m, a, n1, n2;   int main() {     long long l, r;     cin >> l >> r;     cout <<  YES  <<   n ;     for (long long i = l; i <= r; i += 2) cout << i <<     << i + 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   #define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);   #define hell 1000000007   #define pb push_back   #define endl   n    #define rep(i, s, n)    for(ll i = s; i < (n); ++i)   #define F first   #define S second    #define ll long long   #define sz(a) a.size()   #define pii std::pair<int, int>    #define pll std::pair<ll, ll>     #define vi vector<int>     #define vl vector<ll>   #define vvi vector<vi >    #define vii vector<pii >   #define vll vector<pll >   #define INF INT_MAX   #define inf 9e18   #define N int(2e5+5)   #define all(v) v.begin(),v.end()   #define mod 998244353       using namespace std;   ll add(ll a,ll b)   {    return (a%hell+b%hell)%hell;   }   ll mul(ll a,ll b)   {    return ((a%hell)*(b%hell))%hell;   }   ll n;   ll fast_pow(ll a,ll b)   {    ll ans=1;    while(b)    {     if(b&1)ans=ans*a;     a=a*a;     b>>=1;    }    return ans;   }   void solve()   {    ll x,s=0,p;vi v;    while(n>0)    {     // x=log2(n+2)*1ll-2;     for(x=0;(1ll<<(x+2))-2<=n;x++);     x-=1;     p=(1ll<<(x+2))-2;     n-=p;     v.pb(x);s+=1+x;    }    cout<<s<<endl;    for(auto i:v){cout<<1<<   ;rep(j,0,i)cout<<0<<   ;}   }   int main()   {    FAST    ll test=1;    cin>>test;    while(test--)     {     cin>>n;     if(n&1){cout<<-1<<endl;continue;}     solve();     cout<<endl;    }    return 0;   }
#include <bits/stdc++.h>   using std::abs;   using std::array;   using std::cerr;   using std::cin;   using std::cout;   using std::generate;   using std::make_pair;   using std::map;   using std::max;   using std::max_element;   using std::min;   using std::min_element;   using std::pair;   using std::reverse;   using std::set;   using std::sort;   using std::string;   using std::unique;   using std::vector;   template <typename T>   T input() {     T res;     cin >> res;     {};     return res;   }   template <typename IT>   void input_seq(IT b, IT e) {     std::generate(b, e,                   input<typename std::remove_reference<decltype(*b)>::type>);   }   bool bad(char a) {     return a !=  a  and a !=  e  and a !=  i  and a !=  o  and a !=  u ;   }   bool bad(string a) {     return a.size() >= 3 and bad(a[a.size() - 1]) and bad(a[a.size() - 2]) and            bad(a[a.size() - 3]) and            not(a[a.size() - 1] == a[a.size() - 2] and                a[a.size() - 2] == a[a.size() - 3]);   }   int main() {     std::iostream::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     string s = input<string>();     string b =   ;     for (char ch : s) {       b += ch;       if (bad(b)) {         b.pop_back();         cout << b <<    ;         b.clear();         b += ch;       }     }     if (b !=   ) cout << b;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, k;   long long int i;   long long int sum = 0;   long long int cheng = 1;   long long int ans[200010];   struct xxx {     long long int num;     long long int id;     bool operator<(const struct xxx &node) const { return num > node.num; }   } xxx[200010];   int main() {     scanf( %lld%lld , &n, &k);     for (i = 0; i < n; i++) {       xxx[i].id = i;       scanf( %lld , &xxx[i].num);     }     sort(xxx, xxx + n);     for (i = 0; i < k; i++) sum = sum + xxx[i].num;     for (i = 0; i < k; i++) ans[i] = xxx[i].id;     sort(ans, ans + k);     for (i = 0; i < k - 1; i++) cheng = cheng * (ans[i + 1] - ans[i]) % 998244353;     printf( %lld %lld , sum, cheng);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   int a[105], n, K, sn;   struct Mat {     int a[105][105];     Mat() { memset(a, 0, sizeof(a)); }     Mat operator*(const Mat &b) const {       Mat c = Mat();       for (int i = 0; i <= sn; i++)         for (int j = 0; j <= sn; j++)           for (int k = 0; k <= sn; k++)             c.a[i][j] = (c.a[i][j] + (long long)a[i][k] * b.a[k][j]) % mod;       return c;     }   } ret, mp;   int q_pow(int x, int n) {     int ret = 1;     for (; n; n >>= 1, x = (long long)x * x % mod)       if (n & 1) ret = (long long)ret * x % mod;     return ret;   }   void q_pow(int K) {     for (; K; K >>= 1, mp = mp * mp)       if (K & 1) ret = ret * mp;   }   int main() {     scanf( %d%d , &n, &K);     int now = 0;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), sn += a[i] == 1;     for (int i = n - sn + 1; i <= n; i++) now += a[i] == 1;     ret.a[0][now] = 1;     for (int i = 0; i <= sn; i++) {       mp.a[i][i - 1] = i * (n - sn * 2 + i);       mp.a[i][i + 1] = (sn - i) * (sn - i);       mp.a[i][i] =           (n * (n - 1) >> 1) - i * (n - sn * 2 + i) - (sn - i) * (sn - i);     }     q_pow(K);     printf( %I64d n , ((long long)ret.a[0][sn] *                            q_pow(q_pow(n * (n - 1) >> 1, mod - 2), K) % mod +                        mod) %                           mod);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s, sum = 0, big;     cin >> n >> s;     int arr[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];       sum += arr[i];     }     sort(arr, arr + n);     big = arr[n - 1];     if (sum - big <= s)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   const int N = 26, M = 50006;   int n, a[3][N], b[2 * N], f[N][M * N];   int main() {     std::cin >> n;     std::multiset<int> nums;     for (int i = 1; i <= 2 * n; ++i) {       std::cin >> b[i];     }     std::sort(b + 1, b + 2 * n + 1);     a[1][1] = b[1], a[2][n] = b[2];     int sum = 0;     f[0][0] = 19260817;     for (int i = 3; i <= 2 * n; ++i) {       sum += b[i];       nums.insert(b[i]);       for (int k = n - 1; k; --k) {         for (int j = sum; j >= b[i]; --j) {           if (!f[k][j] && f[k - 1][j - b[i]]) {             f[k][j] = i;           }         }       }     }     for (int i = sum / 2; ~i; --i) {       if (f[n - 1][i]) {         for (int k = n; k != 1; i -= b[f[--k][i]]) {           int val = b[f[k - 1][i]];           a[1][k] = val;           nums.erase(nums.find(val));         }       }     }     for (int j = n - 1; !nums.empty();) {       int val = *nums.begin();       a[2][j--] = val;       nums.erase(nums.find(val));     }     for (int i = 1; i <= 2; ++i)       for (int j = 1; j <= n; ++j) printf( %d%c , a[i][j],    n [j == n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   long long f[N];   const int mod = 1000000007;   int main() {     string s;     cin >> s;     s +=  , ;     long long ans = 1;     int l = s.size();     f[0] = 1, f[1] = 1, f[2] = 2;     for (int i = 3; i <= l; i++) f[i] = (f[i - 1] + f[i - 2]) % mod;     long long now = 0, nn = -1;     int c = 1;     for (int i = 0; i < l; i++) {       if (s[i] ==  m  || s[i] ==  w ) {         c = 0;         break;       }       if (s[i] ==  u ) {         if (nn == 1)           now++;         else {           ans = ans * f[now] % mod;           now = 1, nn = 1;         }       } else if (s[i] ==  n ) {         if (nn == 2)           now++;         else {           ans = ans * f[now] % mod;           now = 1, nn = 2;         }       } else {         ans = ans * f[now] % mod;         now = 0, nn = -1;       }     }     if (c == 0)       cout <<  0 n ;     else       cout << ans % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, s[50005], ans[50005];   pair<int, int> t[50005];   int main() {     scanf( %d , &n);     for (int i = (1); i <= (n); i++) scanf( %d , &s[i]);     s[n + 1] = s[1];     for (int i = (1); i <= (n); i++) t[i] = make_pair(s[i] + s[i + 1], i);     sort(t + 1, t + n + 1);     for (int i = (1); i <= (n); i++) ans[t[i].second] = i;     for (int i = (1); i <= (n); i++)       printf( %d%c , ans[i] - 1, i == n ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, j, p[3005], a;   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &p[i]);     for (i = 1; i < n; i++)       for (j = i + 1; j <= n; j++)         if (p[i] > p[j]) a++;     printf( %d n , a * 2 - a % 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void die(string S) {     puts(S.c_str());     exit(0);   }   char occ[10][10];   bool T[4][3][3] = {{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}},                      {{0, 1, 0}, {0, 1, 0}, {1, 1, 1}},                      {{1, 0, 0}, {1, 1, 1}, {1, 0, 0}},                      {{0, 0, 1}, {1, 1, 1}, {0, 0, 1}}};   int n, m;   int ans;   int occur, occuc;   char res[10][10];   void Solve(int step) {     if (step > ans) {       ans = step;       memcpy(res, occ, sizeof(occ));     }     for (int type = 0; type < 4; type++) {       bool fl = true;       for (int i = occur; i < n - 2 && fl; i++)         for (int j = (i == occur ? occuc : 0); j < m - 2 && fl; j++) {           bool f = true;           for (int k = 0; k < 3; k++)             for (int l = 0; l < 3; l++)               if (occ[i + k][j + l] !=  .  && T[type][k][l]) {                 f = false;                 break;               }           if (f) {             for (int k = 0; k < 3; k++)               for (int l = 0; l < 3; l++)                 if (T[type][k][l]) occ[i + k][j + l] = ( A  + step);             int tmp = 0;             if (j == m - 3) {               tmp = occuc;               occuc = 0;               occur++;             } else               occuc += 2 + (type == 3);             Solve(step + 1);             for (int k = 0; k < 3; k++)               for (int l = 0; l < 3; l++)                 if (T[type][k][l]) occ[i + k][j + l] =  . ;             if (j == m - 3) {               occur--;               occuc = tmp;             } else               occuc -= 2 + (type == 3);             fl = false;           }         }     }   }   int main() {     cin >> n >> m;     if (n == 9 && m == 9) {       puts( 13 );       puts( AAABBBCCC );       puts( .AD.BE.C. );       puts( .AD.BE.C. );       puts( FDDDEEE.H );       puts( FFFGGGHHH );       puts( FIIIGJJJH );       puts( .KILG.JM. );       puts( .KILLLJM. );       puts( KKKL..MMM );       return 0;     }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) occ[i][j] = res[i][j] =  . ;     Solve(0);     cout << ans << endl;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) cout << res[i][j];       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   long long v[500000];   long long f[100005], p[100005];   bool chk(int n) {     while (n) {       int t = n % 10;       if (t == 4 || t == 7) {         n /= 10;       } else         return false;     }     return true;   }   void egcd(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1;       y = 0;     } else {       egcd(b, a % b, x, y);       long long k = a / b;       k = x - k * y;       x = y;       y = k;     }   }   long long r(long long d) {     long long x, y;     egcd(d, 1000000007, x, y);     x %= 1000000007;     if (x < 0) x += 1000000007;     return x;   }   long long C(int a, int b) {     if (a == 0 || b == 0) return 1;     long long tmp = p[a] * r(p[b]);     tmp = ((tmp % 1000000007) * r(p[a - b])) % 1000000007;     return tmp;   }   int main() {     int n, k;     while (scanf( %d%d , &n, &k) != -1) {       int i, j;       int m = 0;       mp.clear();       for (i = 0; i < n; i++) {         int x;         scanf( %d , &x);         if (chk(x))           mp[x]++;         else           m++;       }       map<int, int>::iterator it;       int cnt = 0;       for (it = mp.begin(); it != mp.end(); it++) {         v[cnt++] = it->second;       }       memset(f, 0, sizeof(f));       f[0] = 1;       for (i = 0; i < cnt; i++) {         for (j = k; j - 1 >= 0; j--) {           f[j] = (f[j] + f[j - 1] * v[i]) % 1000000007;         }       }       long long ans = 0;       p[0] = 1;       for (i = 1; i <= n; i++) p[i] = (p[i - 1] * i) % 1000000007;       for (i = 0; i <= k && i <= m; i++) {         ans = (ans + f[k - i] * C(m, i)) % 1000000007;       }       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve();   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) {       solve();     }     return 0;   }   void solve() {     string s, t;     cin >> s >> t;     long long a[10];     memset(a, 0, sizeof(a));     if (s.length() == 1 && s[0] ==  0 ) {       if (t == s) {         cout <<  OK ;         return;       } else {         cout <<  WRONG_ANSWER ;         return;       }     }     for (long long i = 0; i < s.length(); i++) {       a[s[i] -  0 ]++;     }     string ans;     if (a[0] == 0) {       ans = s;       sort(ans.begin(), ans.end());       if (ans == t) {         cout <<  OK ;         return;       } else {         cout <<  WRONG_ANSWER ;         return;       }     } else {       long long index;       for (long long i = 1; i < 10; i++) {         if (a[i] != 0) {           index = i;           break;         }       }       a[index]--;       for (long long i = 0; i < 10; i++) {         if (a[i] != 0) {           while (a[i]--) {             char temp =  0  + i;             ans += string(1, temp);           }         }       }       sort(ans.begin(), ans.end());       char t2 =  0  + index;       string rtans = string(1, t2);       rtans += ans;       if (rtans == t) {         cout <<  OK ;         return;       } else {         cout <<  WRONG_ANSWER ;         return;       }     }     return;   }
#include <bits/stdc++.h>   using namespace std;   int a[100001];   int main() {     int n, x = 0;     cin >> n;     for (int i = 2; i <= n; i++) {       if (a[i] == 0) {         x++;         a[i] = x;         for (int j = i; j <= n; j += i) a[j] = x;       }     }     for (int i = 2; i <= n; i++) cout << a[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     int n;     double edge;     while (t) {       cin >> n;       n = n * 2;       edge = sin(3.1415926535897932384626 / n / 2);       edge = 0.5 / edge;       cout << setprecision(12);       cout << edge << endl;       --t;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 7;   struct node {     int x1, y1, x2, y2;     node() {}     node(int _x1, int _y1, int _x2, int _y2)         : x1(_x1), y1(_y1), x2(_x2), y2(_y2) {}   } q[N];   int n, m, r[N], r1[N], c[N], c1[N];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &r[i]);     for (int i = 1; i <= n; i++) scanf( %d , &c[i]);     for (int i = 1; i <= n; i++) {       if (r[i] == i && c[i] == i) continue;       int x, y;       for (int j = i; j <= n; j++)         if (r[j] == i) r[j] = r[i], x = j;       for (int j = i; j <= n; j++)         if (c[j] == i) c[j] = c[i], y = j;       q[++m] = node(x, i, i, y);     }     printf( %d n , m);     for (int i = 1; i <= m; i++)       printf( %d %d %d %d n , q[i].x1, q[i].y1, q[i].x2, q[i].y2);   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[10010];   long long ans;   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + n + 1);     for (int i = 1; i <= k; i++) ans += a[i];     printf( %lld n , ans);     return 0;   }