malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>      using namespace std;   typedef long long ll;      void solve() {       int a, b, k; cin >> a >> b >> k;       vector<int> A(k);       vector<int> B(k);       vector<int> cA(a + 1);       vector<int> cB(b + 1);       ll ans = 0;       for (int i = 0; i < k; i++) {           cin >> A[i];           cA[A[i]]++;       }       for (int i = 0; i < k; i++) {           cin >> B[i];           cB[B[i]]++;       }       for (int i = 0; i < k; i++) {           ans += k - cA[A[i]] - cB[B[i]] + 1;       }       cout << ans / 2 <<   n ;   }      int main() {       ios::sync_with_stdio(false);       cin.tie(nullptr);       int t; cin >> t;       while(t--) solve();       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t-- > 0) {       int n;       cin >> n;       int a[n];       cin >> a[0];       for (int i = 1; i < n; i++) {         cin >> a[i];       }       vector<int> v;       for (int i = 1; i < n - 1; i++) {         if ((a[i] > a[i - 1] && a[i] > a[i + 1]) ||             (a[i] < a[i - 1] && a[i] < a[i + 1]))           v.push_back(a[i]);       }       cout << v.size() + 2 << endl;       cout << a[0] <<    ;       for (auto i = v.begin(); i != v.end(); ++i) {         cout << *i <<    ;       }       cout << a[n - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int e = 0; e < t; e++) {       long long n;       cin >> n;       vector<bool> used(n + 2, false);       long long q;       long long last = -1;       vector<long long> ans;       long long index = 1;       for (int i = 0; i < n; i++) {         cin >> q;         if (q != last) {           ans.push_back(q);           last = q;           used[q] = true;           continue;         }         while (used[index]) {           index++;           if (index >= q) {             index = -1;             break;           }         }         if (index == -1) {           cout << -1 << endl;           while (i < n - 1) {             cin >> q;             i++;           }           break;         }         ans.push_back(index);         used[index] = true;         continue;       }       if (index != -1)         for (int i = 0; i < ans.size(); i++) {           cout << ans[i] <<    ;         }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T read() {     T sum = 0, fl = 1;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) fl = -1;     for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch -  0 ;     return sum * fl;   }   const int maxn = 5000 + 5;   const int maxm = 1e5 + 5;   int n, m, k, c;   long long mx[maxn];   bool del[maxm << 1], no[maxm];   int fa[maxn], id[maxm << 1];   vector<int> vec, E;   int he[maxn], ne[maxm << 1], to[maxm << 1], w[maxm << 1];   struct EDGE {     int u, v, w, id;   } e[maxm];   bool operator<(const EDGE& a, const EDGE& b) { return a.w < b.w; }   void add_edge(int u, int v, int val) {     ne[++c] = he[u];     he[u] = c;     to[c] = v;     w[c] = val;     ne[++c] = he[v];     he[v] = c;     to[c] = u;     w[c] = val;   }   int find(int first) {     return fa[first] == first ? first : fa[first] = find(fa[first]);   }   void forest() {     for (int i = 1; i <= n; ++i) fa[i] = i;     sort(e + 1, e + m + 1);     for (int i = 1; i <= m; ++i) {       int u = find(e[i].u), v = find(e[i].v);       if (u == v || u == 1 || v == 1) continue;       fa[u] = v;       E.push_back(e[i].id);       add_edge(e[i].u, e[i].v, e[i].w);       id[c] = id[c - 1] = e[i].id;     }   }   void get_max(int p, int f) {     for (int i = he[p]; i; i = ne[i]) {       if (to[i] == f || del[i] || to[i] == 1) continue;       if (w[i] >= w[mx[p]])         mx[to[i]] = i;       else         mx[to[i]] = mx[p];       get_max(to[i], p);     }   }   void Solve() {     n = read<int>(), m = read<int>(), k = read<int>();     c = 1;     for (int i = 1; i <= m; ++i)       e[i] = (EDGE){read<int>(), read<int>(), read<int>(), i};     forest();     for (int i = 1; i <= m; ++i) {       if (e[i].u != 1 && e[i].v != 1) continue;       int u = find(e[i].u), v = find(e[i].v);       if (u == v)         vec.push_back(i);       else         fa[u] = v, add_edge(e[i].u, e[i].v, e[i].w), E.push_back(e[i].id), --k;     }     for (int i = 2; i <= n; ++i)       if (find(i) != find(i - 1)) return (void)printf( -1 );     if (k < 0) return (void)printf( -1 );     for (int i = 1; i <= k; ++i) {       memset(mx, 0, sizeof(mx));       for (int j = he[1]; j; j = ne[j]) get_max(to[j], 1);       int now = -1, ans = 2147483647;       for (int j = vec.size() - 1; j >= 0; --j) {         int p = vec[j], var = max(e[p].u, e[p].v);         if (e[p].w - w[mx[var]] < ans) ans = e[p].w - w[mx[var]], now = j;       }       int p = vec[now], var = e[p].u == 1 ? e[p].v : e[p].u;       add_edge(e[p].v, e[p].u, e[p].w);       E.push_back(e[p].id);       no[id[mx[var]]] = 1;       del[mx[var]] = del[mx[var] ^ 1] = 1;       vec.erase(vec.begin() + now);     }     printf( %d n , n - 1);     for (int i = E.size() - 1; i >= 0; --i)       if (!no[E[i]]) printf( %d  , E[i]);   }   int main() {     Solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k, a[10000];     cin >> n;     cin >> m;     string s[1000], f[1000];     for (int i = 0; i < n; i++) {       cin >> s[i];     }     for (int i = 0; i < m; i++) {       cin >> f[i];     }     cin >> k;     for (int i = 0; i < k; i++) {       cin >> a[i];     }     for (int i = 0; i < k; i++) {       a[i]--;       cout << s[a[i] % n] << f[a[i] % m] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   long long a[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t, n, k;     cin >> t;     while (t--) {       cin >> n;       string ans, e, ant;       bool ok = 0;       for (int i = 0; i < (int)n - 2; i++) {         cin >> e;         if (!i)           ans += e[0];         else if (e[0] == ant[1])           ans += e[0];         else           ans += ant[1], ans += e[0], ok = 1;         ant = e;       }       ans += ant[1];       if (!ok) ans +=  b ;       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int MAXN = 1000;   int n;   set<int> s[4];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       int tmp;       for (int j = 1; j <= 6; j++) cin >> tmp, s[i].insert(tmp);     }     int i;     for (i = 1; i <= MAXN; i++) {       if (i == MAXN) break;       multiset<int> ms;       int t = i;       while (t > 0) {         ms.insert(t % 10);         t /= 10;       }       for (int j = 1; j <= n; j++) {         for (auto x : ms)           if (s[j].count(x) > 0) {             ms.erase(ms.find(x));             break;           }       }       if (ms.empty()) continue;       ms.clear();       t = i;       while (t > 0) {         ms.insert(t % 10);         t /= 10;       }       for (int j = n; j > 0; j--) {         for (auto x : ms)           if (s[j].count(x) > 0) {             ms.erase(ms.find(x));             break;           }       }       if (ms.empty()) continue;       break;     }     cout << i - 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   long long n;   long long fa[1010000], lg[1010000];   long long cnt[1010000], maxx = 0;   long long a[1010000];   long long find(long long x) {     if (x == fa[x]) return x;     return fa[x] = find(fa[x]);   }   signed main() {     n = read();     long long ans = 0;     for (long long i = 1; i <= n; i++)       a[i] = read(), maxx = max(maxx, a[i]), ans -= a[i], cnt[a[i]]++;     for (long long i = 1; i <= maxx; i++) fa[i] = i, lg[i] = lg[i >> 1] + 1;     cnt[0]++;     long long m = 1 << (lg[maxx] + 1);     for (register long long i = m - 1; ~i; i--) {       for (long long j = i; j * 2 > i; j = (j - 1) & i) {         long long x = j, y = i ^ j;         if (!cnt[x] || !cnt[y]) continue;         x = find(x), y = find(y);         if (x != y) {           ans += i * (cnt[x] + cnt[y] - 1);           fa[x] = y;           cnt[y] = 1;         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long q, n;   int main() {     cin >> q;     for (int i = 0; i < q; i++) {       cin >> n;       vector<long long> nums;       long long cSum = 0, power = 0;       while (cSum < n) {         cSum += pow(3, power);         nums.push_back(pow(3, power));         power++;       }       for (long long j = nums.size() - 1; j >= 0; j--) {         if (cSum - nums[j] >= n) cSum -= nums[j];       }       cout << cSum <<   n ;     }   }
#include <bits/stdc++.h>   #pragma warning(disable : 4786)   using namespace std;   long long heads[100005], tracks[100005];   int n, m;   long long Abs(long long x) { return x < 0 ? -x : x; }   int check(long long x) {     int i, j = 0;     for (i = 0; i < n; i++) {       if (Abs(heads[i] - tracks[j]) > x) continue;       int lo = j, hi = m - 1, k = -1;       while (lo <= hi) {         int mid = (lo + hi) / 2;         long long t1 = Abs(heads[i] - tracks[mid]) + tracks[mid] - tracks[j];         long long t2 = Abs(heads[i] - tracks[j]) + tracks[mid] - tracks[j];         long long t = ((t1) < (t2) ? (t1) : (t2));         if (t <= x)           k = mid, lo = mid + 1;         else           hi = mid - 1;       }       if (k < 0) continue;       j = k + 1;       if (j == m) return 1;     }     return 0;   }   int main() {     int i, j, k, T;     cin >> n >> m;     for (i = 0; i < n; i++) cin >> heads[i];     for (i = 0; i < m; i++) cin >> tracks[i];     long long lo = 0, hi = 1;     for (i = 0; i < 16; i++) hi *= (long long)10;     long long ans = -1;     while (lo <= hi) {       long long mid = (lo + hi) / 2;       if (check(mid))         ans = mid, hi = mid - 1;       else         lo = mid + 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   const int mod = (int)1e9 + 7;   const long long INF = 10000005;   const int inf = 1 << 30;   char buf[1000];   const int N = 210;   vector<int> dep[N];   vector<int> computer[3];   bool completed[N];   int n;   int check(int start) {     int tot = 0, done = 0;     memset(completed, false, sizeof(completed));     while (done < n) {       bool found = true;       while (found) {         found = false;         for (vector<int>::iterator i = computer[start].begin();              i != computer[start].end(); ++i) {           if (!completed[*i]) {             bool cando = true;             for (vector<int>::iterator j = dep[*i].begin(); j != dep[*i].end();                  ++j) {               if (!completed[*j]) {                 cando = false;                 break;               }             }             if (cando) {               done++;               completed[*i] = true;               found = true;             }           }         }       }       if (done < n) {         tot++;         start = (start + 1) % 3;       }     }     return tot;   }   int main() {     cin >> n;     int tmp;     for (int i = 0; i < n; ++i) {       scanf( %d , &tmp);       computer[tmp - 1].push_back(i);     }     for (int i = 0; i < n; ++i) {       int d;       scanf( %d , &d);       for (int j = 0; j < d; ++j) {         scanf( %d , &tmp);         dep[i].push_back(tmp - 1);       }     }     cout << n + min(check(0), min(check(1), check(2))) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x7fffffff;   const double eps = 1e-10;   const double pi = acos(-1.0);   inline int read() {     int x = 0, f = 1;     char ch;     ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = 0;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + (ch & 15);       ch = getchar();     }     if (f)       return x;     else       return -x;   }   const int N = 5010;   int n, a, b;   int val[N], nex[N], ans;   char s[N];   int main() {     n = read();     a = read();     b = read();     memset(val, 0x3f, sizeof(val));     val[0] = 0;     scanf( %s , s + 1);     for (int i = 1; i <= n; i++) {       val[i] = min(val[i], val[i - 1] + a);       nex[i] = i - 1;       int p = i - 1;       for (int j = i + 1; j <= n; j++) {         while (p >= i && s[j] != s[p + 1]) p = nex[p];         if (s[j] == s[p + 1]) p++;         nex[j] = p;       }       p = i - 1;       for (int j = 1; j <= i - 1; j++) {         while (p >= i && s[j] != s[p + 1]) p = nex[p];         if (s[j] == s[p + 1]) p++;         if (p >= i) val[p] = min(val[p], val[i - 1] + b);       }     }     printf( %d n , val[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200004], n, m;   int c[400004];   long long greaterc(int m) {     long long ans = 0, add = 0;     memset(c, 0, sizeof(c));     int div = n;     c[n] = 1;     for (int i = 0; i < n; i++) {       if (a[i] < m)         div--, add -= c[div];       else         add += c[div], div++;       ans += add;       c[div]++;     }     return ans;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     cout << greaterc(m) - greaterc(m + 1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 998244353;   const int N = 100005;   const double PI = 4 * atan(1);   const double eps = 1e-7;   const long long oo = 1e18;   const int AlPHA = 26, B = 30;   long long n, m, L, sr, t;   long long adj[1005][1005];   long long yes[1005][1005];   long long dist[1005];   vector<long long> ad[N];   bool vis[1005];   vector<pair<long long, long long> > v;   void dijkstra(long long src) {     set<pair<long long, long long> > ss;     pair<long long, long long> ras;     for (int i = 0; i < n; i++) {       dist[i] = 1e17;       vis[i] = 0;     }     dist[src] = 0;     ss.insert(make_pair(0, src));     while (!ss.empty()) {       ras = *(ss.begin());       ss.erase(ss.begin());       src = ras.second;       long long w = ras.first;       if (vis[src]) continue;       vis[src] = 1;       for (auto u : ad[src]) {         if (dist[u] > w + adj[src][u]) {           dist[u] = w + adj[src][u];           ss.insert(make_pair(dist[u], u));         }       }     }   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> m >> L >> sr >> t;     for (int i = 0; i < m; i++) {       long long x, y, z;       cin >> x >> y >> z;       ad[x].push_back(y);       ad[y].push_back(x);       if (z > 0) {         adj[x][y] = adj[y][x] = z;       } else {         adj[x][y] = adj[y][x] = 1;         yes[x][y] = yes[y][x] = 1;         v.push_back(make_pair(x, y));       }     }     dijkstra(sr);     long long x = dist[t];     long long i = 0;     while (i < v.size() && x < L) {       long long y = L - x + 1;       adj[v[i].first][v[i].second] = adj[v[i].second][v[i].first] = y;       dijkstra(sr);       x = dist[t];       i++;     }     if (x != L) {       cout <<  NO ;       return 0;     } else {       cout <<  YES n ;       for (int i = 0; i < n; i++) {         for (int j = i + 1; j < n; j++) {           if (adj[i][j]) cout << i <<     << j <<     << adj[i][j] <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T read(T& x) {     x = 0;     int f = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) f |= (ch ==  - ), ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x = f ? -x : x;   }   const int N = 3e5 + 10;   int n, i, j, len, ans = -1, a[N];   int main() {     read(n);     for (i = 1; i <= n; ++i) read(a[i]);     int mn = -1;     for (i = 1, j = n, len = n - 1; i <= j; ++i, --j, --len) {       if (mn == -1)         mn = min(a[i], a[j]);       else         mn = min(mn, min(a[i], a[j]));       int k = mn / len;       if (k < 0) continue;       if (ans == -1)         ans = k;       else         ans = min(ans, k);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   int CASE = 1;   const int mxn = 2e5 + 1;   const long long INF = 1e18;   bool prime(int n) {     if (n <= 1) return false;     if (n == 2 or n == 3) return true;     if (n % 2 == 0 or n % 3 == 0) return false;     for (int i = 5; i * i <= n; i += 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   long long __gcd(long long a, long long b) { return !b ? a : __gcd(b, a % b); }   void solve() {     string s;     cin >> s;     vector<string> v;     while (s.find( > ) != -1) {       string str = s.substr(0, s.find( > ) + 1);       s.erase(0, str.length());       v.push_back(str);     }     int cnt = 0;     map<char, vector<int> > mp;     for (string str : v) {       if (str.find( / ) != -1) {         for (long long i = 0; i < mp[str[str.length() - 2]].back(); i++)           cout <<    ;         cout << str << endl;         mp[str[str.length() - 2]].pop_back();         cnt -= 2;       } else {         mp[str[str.length() - 2]].push_back(cnt);         for (long long i = 0; i < cnt; i++) cout <<    ;         cout << str << endl;         cnt += 2;       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T = 1;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   long long power(long long base, long long expo) {     if (base <= 1) return 1;     long long ans = 1;     while (expo) {       if (expo & 1) {         ans = (ans * base) % n;       }       base = (base * base) % n;       expo >>= 1;     }     return ans;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     if (n == 4) {       cout <<  YES n1 n3 n2 n4 n ;       return 0;     }     for (long long i = 2; i * i <= n; i++) {       if (n % i == 0) {         cout <<  NO ;         return 0;       }     }     vector<long long> mark(n);     cout <<  YES n ;     for (long long i = 1; i <= n; i++) {       long long prnt = i * power(i - 1, n - 2) % n;       assert(!mark[prnt]);       mark[prnt] = 1;       if (!prnt) prnt += n;       cout << prnt << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k = 0;     string ans =   ;     cin >> n;     while (n > 1) {       ans +=  8 ;       k += 1;       n -= 2;     }     if (n == 1) {       ans +=  9 ;       k++;       n--;     }     if (k < 19)       cout << ans;     else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int a, b, c, m;     cin >> a >> b >> c >> m;     vector<long long int> usb;     vector<long long int> p;     for (long long int i = 0; i < m; i++) {       string s;       long long int x;       cin >> x >> s;       if (s ==  USB )         usb.push_back(x);       else         p.push_back(x);     }     sort(usb.begin(), usb.end());     sort(p.begin(), p.end());     long long int pos1 = 0, pos2 = 0, sum = 0, cnt = 0;     for (int i = 0; i < usb.size() && i < a; i++) {       sum += usb[i];       pos1 = i + 1;       cnt++;     }     for (int i = 0; i < p.size() && i < b; i++) {       sum += p[i];       pos2 = i + 1;       cnt++;     }     if (pos1 < usb.size() && pos2 < p.size()) {       long long int cnt2 = 0;       while (pos1 < usb.size() && pos2 < p.size() && cnt2 < c) {         if (usb[pos1] <= p[pos2]) {           sum += usb[pos1];           cnt++;           cnt2++;           pos1++;         } else {           sum += p[pos2];           cnt++;           cnt2++;           pos2++;         }       }       while (pos1 < usb.size() && cnt2 < c) {         sum += usb[pos1];         cnt++;         cnt2++;         pos1++;       }       while (pos2 < p.size() && cnt2 < c) {         sum += p[pos2];         cnt++;         cnt2++;         pos2++;       }     } else if (pos1 < usb.size()) {       long long int cnt2 = 0;       while (pos1 < usb.size() && cnt2 < c) {         sum += usb[pos1];         cnt++;         cnt2++;         pos1++;       }     } else if (pos2 < p.size()) {       long long int cnt2 = 0;       while (pos2 < p.size() && cnt2 < c) {         sum += p[pos2];         cnt++;         cnt2++;         pos2++;       }     }     cout << cnt <<     << sum;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, vector<long long> > M;   set<long long> S;   const long long N = 1000001;   long long n, a[1000001], f[N];   void upd(long long i, long long mx) {     for (; i > 0; i -= (i & -i)) {       f[i] = max(f[i], mx);     }   }   long long get(long long i) {     long long mx = -N;     for (; i < N; i += (i & -i)) mx = max(mx, f[i]);     return mx;   }   signed main() {     ios_base ::sync_with_stdio(false);     cin.tie(0);     cin >> n;     vector<long long> v;     for (long long i = 1; i <= n; ++i) {       cin >> a[i];       v.push_back(a[i]);     }     sort(v.begin(), v.end());     v.resize(unique(v.begin(), v.end()) - v.begin());     for (long long i = 1; i <= n; ++i) {       a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;     }     for (long long i = 1; i <= n; ++i) {       if ((abs(get(a[i]) - i) - 1) % 2 != 0) {         cout <<  NO ;         return 0;       }       upd(a[i], i);     }     for (long long i = 0; i < N; ++i) f[i] = -(n + 1);     for (long long i = n; i >= 1; --i) {       if ((abs(abs(get(a[i])) - i) - 1) % 2 != 0) {         cout <<  NO ;         return 0;       }       upd(a[i], -i);     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   constexpr int Maxn = 53;   std::vector<int> e[Maxn];   int n, m;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1, u, v; i <= m; ++i) {       scanf( %d%d , &u, &v);       if (u <= 50 && v <= 50) {         e[u].emplace_back(v);         e[v].emplace_back(u);       }     }     n = std::min(n, 50);     for (int i = 1; i <= n; ++i) std::sort(e[i].begin(), e[i].end());     for (int i = 1; i <= n; ++i)       for (int j = 1; j < i; ++j)         for (int k = 1; k < j; ++k)           for (int l = 1; l < k; ++l)             for (int r = 1; r < l; ++r) {               std::vector<int> vec = {i, j, k, l, r};               int cnt = 0;               for (int x : {0, 1, 2, 3, 4})                 for (int y = 0; y < x; ++y) {                   auto iter = std::lower_bound(e[vec[x]].begin(), e[vec[x]].end(),                                                vec[y]);                   if (iter == e[vec[x]].end() || *iter != vec[y]) ++cnt;                 }               if (cnt == 0 || cnt == 10) {                 printf( %d %d %d %d %d n , i, j, k, l, r);                 return 0;               }             }     puts( -1 );   }
#include <bits/stdc++.h>   using namespace std;   const int P = 1e9 + 7;   void mul(int A[2][2], int B[2][2]) {     int r[2][2];     r[0][0] = ((A[0][0] * 1LL * B[0][0] + A[0][1] * 1LL * B[1][0]) % P);     r[0][1] = ((A[0][0] * 1LL * B[0][1] + A[0][1] * 1LL * B[1][1]) % P);     r[1][0] = ((A[1][0] * 1LL * B[0][0] + A[1][1] * 1LL * B[1][0]) % P);     r[1][1] = ((A[1][0] * 1LL * B[0][1] + A[1][1] * 1LL * B[1][1]) % P);     A[0][0] = r[0][0];     A[0][1] = r[0][1];     A[1][0] = r[1][0];     A[1][1] = r[1][1];   }   void matexp(int A[2][2], int B[2][2], int n) {     while (n) {       if (n & 1) mul(A, B);       mul(B, B);       n = n >> 1;     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int x, y, n;     cin >> x >> y >> n;     int A[2][2] = {{1, -1}, {1, 0}};     int ans[2][2] = {{1, 0}, {0, 1}};     matexp(ans, A, n - 1);     int v = ((ans[1][0] * 1LL * y + ans[1][1] * 1LL * x) % P + P) % P;     cout << v;     return 0;   }