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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long D;
  scanf("%lld", &D);

  ll div = lcm(C, D);

  ll bc_div = B / C;
  ll bd_div = B / D;

  ll ac_div = (A - 1) / C;
  ll ad_div = (A - 1) / D;

  ll b_lcm = B / div;
  ll a_lcm = (A - 1) / div;

  ll ans = B - A + 1;
  ans -= (bc_div - ac_div) + (bd_div - ad_div);
  ans += (b_lcm - a_lcm);
  put(ans);

  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


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

int main(void) {
  int n;
  cin >> n;
  ll a[n];
  rep (i, n) cin >> a[i];

  sort(a, a + n);

  ll s[n];
  s[0] = a[0];
  rep (i, n - 1) s[i + 1] = s[i] + a[i + 1];

  int ans = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] * 2 >= a[i + 1]) {
      ans++;
      continue;
    }
    break;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <math.h>
#include <stdlib.h>

using namespace std;
typedef long long int lli;

lli A,B,N;
string huka = "-1";
bool counter = false;


int main(void){
    cin >> N;
    
    int teisuu = sqrt(N);
    
    for(lli i=teisuu; 1<=i; i--){
        int amari = N % i;
        if(amari == 0){
            //cout << i <<endl;
            A = i;
            break;
        }
    }
    
    B = N / A;
    
    cout << A-1 + B-1 <<endl;
    
/*    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            int temp = i*j;
            if(N == temp){
                counter = true;
                cout << "yes" << endl;
                return 0;
            }
        }
    }
    
    cout <<"no"<< endl;*/
    return 0;
}



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


int main () {
  int x, y;
  cin >> x >> y;
  vector<int> group = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  cout << (group.at(x - 1) == group.at(y - 1) ? "Yes": "No") << endl;;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<string,int> P;

int main() {
  int n,m;
  cin >> n >> m;
  int prev=MAX;
  int a,b,c,d;
  string s,t;
  vector<P> v;
  rep(i,n) {
    scanf("%d%*c%d",&a,&b);
    cin >> s;
    scanf("%d%*c%d",&c,&d);
    cin >> t;
    a=a*60+b;c=c*60+d;
    if(a-prev>=m) v.pb(P(s,a-prev));
    prev=c;
  }
  pr(v.size());
  rep(i,v.size()) PR(v[i].F,v[i].S);
  return 0;
}


Measured memory_bytes: 1272
#include <stdio.h>

typedef struct{
    char suit;
    int value;
}   CARD;

void bubbleSort(CARD *);
void selectionSort(CARD *);
int isStable(CARD *, CARD *);
void printcard(CARD *);
void swap(CARD *, CARD *);

int n;

int main(){
    CARD card[36], b_card[36], s_card[36];
    int a;
    scanf("%d",&n);
    for(a = 0; a < n; a++){
        scanf(" %c%d",&card[a].suit,&card[a].value);
        b_card[a] = s_card[a] = card[a];
    }

    bubbleSort(b_card);
    selectionSort(s_card);

    printcard(b_card);
    if(isStable(card,b_card) == 1) printf("Stable\n");
    else printf("Not stable\n");
    printcard(s_card);
    if(isStable(card,s_card) == 1) printf("Stable\n");
    else printf("Not stable\n");

    return 0;
}

void bubbleSort(CARD *c){
    int a, b;
    for(a = 0; a < n; a++){
        for(b = n-1; b > a; b--){
            if(c[b].value < c[b-1].value) swap(&c[b],&c[b-1]);
        }
    }
}

void selectionSort(CARD *c){
    int a, b, min;
    for(a = 0; a < n; a++){
        min = a;
        for(b = a; b < n; b++){
            if(c[b].value < c[min].value) min = b;
        }
        swap(&c[a],&c[min]);
    }
}

int isStable(CARD *in, CARD *out){
    int a, b, i, j;
    for(i = 0; i < n; i++){
        for(j = i+1; j < n; j++){
            for(a = 0; a < n; a++){
                for(b = a+1; b < n; b++){
                    if(in[i].value == in[j].value){
                        if(in[i].suit == out[b].suit && in[j].suit == out[a].suit &&
                           in[i].value == out[b].value && in[j].value == out[a].value) return 0;
                    }
                }
            }
        }
    }
    return 1;
}

void printcard(CARD *c){
    int a;
    for(a = 0; a < n-1; a++){
        printf("%c%d ",c[a].suit,c[a].value);
    }
    printf("%c%d\n",c[a].suit,c[a].value);
}

void swap(CARD *x, CARD *y){
    CARD temp;
    temp = *x;
    *x = *y;
    *y = temp;
}


Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
using namespace std;
const int MAX_V = 1000;
const int INF = 1 << 25;

int V;
struct edge { int to, cap, rev; };

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, int(G[to].size()) });
	G[to].push_back(edge{ from, 0, int(G[from].size() - 1) });
}

void add_edge2(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, int(G[to].size()) });
	G[to].push_back(edge{ from, cap, int(G[from].size() - 1) });
}

int dfs(int v, int t, int f) {
	if(v == t) return f;
	used[v] = true;
	for(edge& e : G[v]) {
		if(!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t, int lim) {
	int flow = 0;
	while(1) {
		fill(used, used + V, false);
		int f = dfs(s, t, lim);
		if(f == 0 || flow == lim) return flow;
		flow += f;
		lim -= f;
	}
	return -1;
}

int M[1000];
int A[1000];
int B[1000];

bool ex[1000][1000];

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

	int N, E, Q;
	cin >> N >> E >> Q;

	int S = N, T = N + 1;
	V = N + 2;
	for(int i = 0; i < E; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		add_edge2(a, b, 1);
		ex[a][b] = ex[b][a] = true;
	}
	for(int i = 0; i < Q; i++) {
		cin >> M[i] >> A[i] >> B[i];
		A[i]--, B[i]--;
		if(!ex[A[i]][B[i]]) {
			add_edge2(A[i], B[i], 0);
			ex[A[i]][B[i]] = ex[B[i]][A[i]] = true;
		}
	}
	add_edge(S, 0, 1000000);
	add_edge(N - 1, T, 1000000);

	int f = max_flow(S, T, INF);

	for(int i = 0; i < Q; i++) {
		int m = M[i], u = A[i], v = B[i];
		if(m == 1) {
			for(edge& e : G[u]) {
				if(e.to == v) {
					e.cap = G[v][e.rev].cap = 1;
					f += max_flow(S, T, 1);
					break;
				}
			}
		}
		else {
			for(edge& e : G[u]) {
				if(e.to == v) {
					int c = e.cap;

					if(c == 0) {// u -> v
						if(max_flow(u, v, 1) == 0) {
							max_flow(T, S, 1);
							assert(max_flow(u, v, 1) != 0);
							//assert(max_flow(u, S, 1) == 1);
							//assert(max_flow(T, v, 1) == 1);
							f--;
						}
					}
					else if(c == 2) {// v -> u
						if(max_flow(v, u, 1) == 0) {
							max_flow(T, S, 1);
							assert(max_flow(v, u, 1) != 0);
							//assert(max_flow(v, S, 1) == 1);
							//assert(max_flow(T, u, 1) == 1);
							f--;
						}
					}
					e.cap = G[v][e.rev].cap = 0;
					break;
				}
			}
		}
		cout << f << endl;
	}

}

Measured memory_bytes: 4108
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

int N, A[200200], R[200200];
vector<int> G[200200], L;

void go(int x, int l)
{
	auto i = lower_bound(L.begin(), L.end(), A[x]) - L.begin();
	int v = -1;

	if (i == L.size()) L.push_back(A[x]);
	else v = L[i], L[i] = A[x];

	R[x] = L.size();

	for (auto &y : G[x]) if (y != l) go(y, x);

	if (v == -1) L.pop_back();
	else L[i] = v;
}

int main()
{
	scanf ("%d", &N);
	for (int i = 1; i <= N; i++) scanf ("%d", &A[i]);
	for (int i = 1; i < N; i++){
		int x, y; scanf ("%d %d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}

	go(1, 0);

	for (int i = 1; i <= N; i++) printf ("%d\n", R[i]);

	return 0;
}

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

using namespace std;
#define mx 200000
int main(){
    string s[]={"SUN", "MON", "TUE","WED" ,"THU" ,"FRI" , "SAT","SUN", "MON", "TUE","WED" ,"THU" ,"FRI" , "SAT"};

    string a;
    cin>>a;
    for(int i=0;i<14;i++){
       if(a==s[i]){

          for(int j=i+1;j<14;j++){
              if(s[j]=="SUN"){
                cout<<(j-i)<<endl;
                return 0;
              }
          }
       }
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
using namespace std;
priority_queue<int> q;

int main()
{
    int n, m; scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++)
    {
        int x; scanf("%d", &x);
        q.push(x);
    }
    for(; m--;)
    {
        int x = q.top();
        q.pop();
        q.push(x / 2);
    }
    long long ans = 0;
    while(q.size())
    {
        ans += 1LL * q.top();
        q.pop();
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 892
#include <iostream>

using namespace std;

long long n, i, j, k, ans, c, r, g, b;
int s[4001];
char x;

int main()
{
    cin >> n;
    for(i = 1; i <= n; i++)
    {
        cin >> x;
        if(x == 'R')
            r++;
        if(x == 'G')
            g++;
        if(x == 'B')
            b++;
        c = x;
        s[i] = c;
    }
    for(i = 1; i <= n; i++)
        for(j = i+1; j <= n; j++)
        {
            k = 2 * j - i;
            if(k <= n)
                if(s[k] != s[i] && s[i] != s[j] && s[k] != s[j])
                    ans++;
        }
    cout << r*g*b - ans;
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cmath>
#include<string>
#include<bits/stdc++.h>
#include<algorithm>
#include<sstream>
using namespace std;

int main()
{

    int a,b;
    cin>>a>>b;
    if(a!=0 && b!=0 && a<10 && b<10)
        cout<< a*b;
    else
        cout<<-1;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
string temp;
int main()
{
    mp["AKIHABARA"]=1;
    mp["KIHABARA"]=1;
    mp["AKIHBARA"]=1;
    mp["AKIHABRA"]=1;
    mp["AKIHABAR"]=1;
    mp["KIHBARA"]=1;
    mp["KIHABRA"]=1;
    mp["KIHABAR"]=1;
    mp["AKIHBRA"]=1;
    mp["AKIHBAR"]=1;
    mp["AKIHABR"]=1;
    mp["KIHBRA"]=1;
    mp["KIHBAR"]=1;
    mp["AKIHBR"]=1;
    mp["KIHABR"]=1;
    mp["KIHBR"]=1;
    cin>>temp;
    if(mp[temp]==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}


Measured memory_bytes: 256
from fractions import gcd


def lcm_base(a, b):
    return (a * b) // gcd(a, b)


A, B, C, D = map(int, input().split())

count_C = B//C - (A+C-1)//C + 1
count_D = B//D - (A+D-1)//D + 1

CD = lcm_base(C, D)
countCD = B//CD - (A+CD-1)//CD + 1

ans = (B-A+1) - count_C - count_D + countCD
print(ans)


Measured memory_bytes: 5076
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll ai, ao, at, aj, al, as, az;
  cin >> ai >> ao >> at >> aj >> al >> as >> az;
  ll cnt = 0;

  cnt += ai - ai%2;
  cnt += ao;
  cnt += aj - aj%2;
  cnt += al - al%2;
  if (ai % 2 + aj % 2 + al % 2 == 2 and ai >0 and aj >0 and al >0) cnt += 1;
  else if (ai % 2 + aj % 2 + al % 2 == 3) cnt += 3;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
/***************************************************************
     File Name: C.cpp
     Created Time: 六  5/ 5 20:31:00 2018
 **************************************************************/
#define MEM0(x) memset(x,0,sizeof(x))
#define MEM1(x) memset(x,-1,sizeof(x))
#define MEMX(x) memset(x,0x3f,sizeof(x))
#include <iostream>
using namespace std;

char s[55][55];
int row, col;

bool judge(int i, int j) {
  if (0 <= i && i < row && 
      0 <= j && j < col &&
      s[i][j] == '#')
    return true;
  return false;
}

bool gao(int i, int j) {
  if (judge(i-1, j) ||
      judge(i+1, j) ||
      judge(i, j-1) ||
      judge(i, j+1))
    return true;
  return false;
}

int main() {
  while (cin >> row >> col) {
    for (int i = 0; i < row; ++i) cin >> s[i];
    // for (int i = 0; i < row; ++i)
    //   cout << s[i] << endl;
    // cout << endl;
    bool flag = false;
    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < col; ++j)
        if (s[i][j] == '#') {
          if (!gao(i, j)) {
            flag = true;
            // printf("s[%d][%d] = %c\n", i, j, s[i][j]);
            break;
          }
        }
      if (flag) break;
    }
    if (flag) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int *A;
  int N,p,q,r,key;

  scanf("%d",&N);
  A=(int *)malloc(N*sizeof(int));

  for(p=0; p<=N-1; p++)
    {
      scanf("%d",&A[p]);
    }

  for(p=1; p<=N-1;p++)
    {
      for(r=0; r<=N-2; r++)
	{
	  printf("%d ",A[r]);
	}
      printf("%d",A[r]);
      printf("\n");
      key=A[p];
      q=p-1;
      while(q>=0 && A[q]>key)
	{
	  A[q+1]=A[q];
	  q--;
	}
      A[q+1]=key;
    }

  for(r=0; r<=N-2; r++)
	{
	  printf("%d ",A[r]);
	}
  printf("%d",A[r]);
  printf("\n");

  return 0;
}

      



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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	int n;
	cin >> n;

	VI v(n);
	REP(i, n)cin >> v[i];
	v[0]--;
	REP(i, n - 1) {
		if (v[i] == v[i + 1])continue;
		else if (v[i] > v[i + 1]) {
			cout << "No" << endl;
			return 0;
		}
		else v[i + 1]--;
	}

	cout << "Yes" << endl;


	
}

Measured memory_bytes: 640
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>
 
#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;
 
#define pb(x) push_back(x)  
#define rep(i,n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define len(p) (sizeof(p)/sizeof(*p))
#define debug(x) cerr << #x << ": " << x << '\n'; 
// #define int long long
 
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
template <class T> void print(T x){ cout << x << '\n'; }
template <class T> void print(T *x, size_t l){ rep(i,l){cout << *(x+i) << ' ';} cout << '\n'; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { int len = v.size(); for (int i = 0; i < len; ++i) { s << v[i]; if (i < len - 1) s << " "; } return s; }
 

int n;
int *a;
int c;
vector<pii> operations;

void dump(){
    cout << c << endl;
    for(auto it = operations.begin(); it != operations.end(); it++){
        cout << it->first << " " << it->second << endl;
    }
    // print(a+1, n);
}

void solveMinus(){
    for(int i = n-1; i >= 1; i--){
        if (a[i] > a[i+1]) {
            c++;
            operations.pb(make_pair(i+1, i));
            a[i] += a[i+1];
        }
    }
    dump();
}
void solvePlus(){
    rep(j, n-1) {
        int i = j+1;
        // cout << i << endl;
        if (a[i] > a[i+1]) {
            c++;
            operations.pb(make_pair(i, i+1));
            a[i+1] += a[i];
        }
    }
    dump();
}

signed main(void){
    cin >> n;
    a = new int[n+2];
    rep(i, n) cin >> a[i+1];

    int count = 0;

    int ma = a[1], mi = a[1];
    int mai = 1, mii = 1;
    rep(j, n) {
        int i = j+1;
        if (ma < a[i]) {ma = a[i]; mai = i;}
        if (mi > a[i]) {mi = a[i]; mii = i;}
    }
    if (mi >= 0) solvePlus(); 
    else if (ma <= 0) solveMinus();
    else {
        c = n-1;
        if( ma > -mi) {
            for(int i = 1; i <= n; i++){
                if( i == mai) continue;
                operations.pb(make_pair(mai, i));
                a[i] += a[mai];
            }
            solvePlus();
        }
        else{
            for(int i = 1; i <= n; i++){
                if( i == mii) continue;
                operations.pb(make_pair(mii, i));
                a[i] += a[mii];
            }
            solveMinus();
        }
    }
}



Measured memory_bytes: 256
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

int n,m;
vector<vector<int>> edges;
vector<int> visited,dist,indeg;

void dfs(int x){
    visited[x] = 1;
    for(int y : edges[x]){
        dist[y] = max(dist[y],dist[x]+1);
        indeg[y]--;
        if(indeg[y]==0)
            dfs(y);
    }
}


void mymain(){
  cin >> n >> m;
  edges.resize(n+1,vi());
  visited.resize(n+1,0);dist.resize(n+1,0);indeg.resize(n+1,1);
  for(int i=0;i<m;i++){
    int x,y;
    cin >> x >> y;
    edges[x].pb(y);
    indeg[y]++;
  }
  for(int i=1;i<=n;i++)
    edges[0].pb(i);
    indeg[0]=0;
  for(int i = 0;i<=n;i++){
    if(!visited[i] && indeg[i] == 0){
        dfs(i);
    }
  }
    int ans = -1;
    for(int i=0;i<=n;i++)
        ans = max(ans,dist[i]);
    cout << ans-1 << endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


Measured memory_bytes: 9972
#include <iostream>
#include <string>

using namespace std;

class Dice
{
public:
	Dice(unsigned int in[6])
	{
		for (int i = 0; i < 6; i++)
		{
			label[i] = in[i];
			//cout << "label[" << i << "]=" << label[i];
		}
		//cout << endl;
		Reset();
	}
	~Dice()
	{
	}
	void Reset()
	{
		N = 5;
		E = 3;
		S = 2;
		W = 4;
		F = 1;
		B = 6;
	}
	void Run(string &cmd)
	{
		for (int i = 0; i < cmd.size(); i++)
		{
			char c = cmd[i];
			if (c == 'S')
			{
				// 3, 4?????????????????????
				int tmpF = F;
				F = N;
				N = B;
				B = S;
				S = tmpF;
			}
			else if (c == 'N')
			{
				// 3, 4?????????????????????
				int tmpN = N;
				N = F;
				F = S;
				S = B;
				B = tmpN;
			}
			else if (c == 'E')
			{
				// 2,5?????????????????????
				int tmpB = B;
				B = E;
				E = F;
				F = W;
				W = tmpB;
			}
			else if (c == 'W')
			{
				int tmpW = W;
				W = F;
				F = E;
				E = B;
				B = tmpW;
			}
		}
	}
	int GetFront()
	{
		return F;
	}
	int GetLabel()
	{
		return label[F-1];
	}
	int GetSouthLabel()
	{
		return label[S-1];
	}
	// ?????°??????????????§N?????????W????????????
	int ThrowTo(int argF, int argS)
	{
		//cout << "DEBUG:Begin ThrowTo(int argF, int argS)" << endl;
		for (int x = 0; x < 4; x++)
		{
			Reset(); // TODO ?????????4??????!!!
			if (x == 0)
			{
			}
			else if (x == 1)
			{
				string cmd1 = "WSE";
				Run(cmd1);
			}
			else if (x == 2)
			{
				string cmd2 = "WSSE";
				Run(cmd2);
			}
			else if (x == 3)
			{
				string cmd3 = "WSSSE";
				Run(cmd3);
			}
			for (int w = 0; w < 4; w++)
			{
				for (int n = 0; n < 4; n++)
				{
					string nnnn = "N";
					Run(nnnn);
					//printf("inArg(%d,%d)   dice[%d,%d]\n", argF, argS, GetLabel(), GetSouthLabel());
					if (GetLabel() == argF && GetSouthLabel() == argS)
					{
						//cout << "HIT:" << label[E-1] << endl;
						return label[E-1];
					}
				}
				string wwww = "W";
				Run(wwww);
			}
		}
		return 1;
	}
private:
	unsigned int label[6];
	int N;
	int E;
	int S;
	int W;
	int F;
	int B;
};

int main()
{
	unsigned int in[6] = {0};
	unsigned int n;
	unsigned int q;
	string cmd;
	for (int i = 0; i < 6; i++)
	{
		cin >> n;
		in[i] = n;
	}
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		int front, south;
		cin >> front >> south;
		
		// ?????´(East)?????¨????????????
		Dice d1(in);
		cout << d1.ThrowTo(front, south) << endl;
	}
	
	/*
	unsigned int in[6] = {1, 2, 3, 4, 5, 6};
	Dice d1(in);
	d1.ThrowTo(6, 5);
	*/
	
	return 0;
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A, B;
	cin >> A >> B;
	bool ok = 0;
	for (int i = 1; i <= 10000; i++) {
		int x = i * 0.08;
		int y = i * 0.1;
		if (x == A && y == B) {
			cout << i << endl;
			ok = 1;
			break;
		}
	}
	if (!ok) cout << -1 << endl;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c;

    if (a > b) {
        d = b;
        b = a;
        a = d;
    }
    if (b > c) {
        d = c;
        c = b;
        b = d;
    }
    if (a > b) {
        d = b;
        b = a;
        a = d;
        cout << a << " " << b << " " << c << endl;
    }
    else cout << a << " " << b << " " << c << endl;
    
    return 0;
}


Measured memory_bytes: 3104
f = list(map(int, input().split()))
q = int(input())
for i in range(q):
	a = list(map(int, input().split()))
	if a in [[f[0], f[1]], [f[1], f[5]], [f[5], f[4]], [f[4], f[0]]]:
		print(f[2])
	elif a in [[f[0], f[2]], [f[2], f[5]], [f[5], f[3]], [f[3], f[0]]]:
		print(f[4])
	elif a in [[f[0], f[4]], [f[4], f[5]], [f[5], f[1]], [f[1], f[0]]]:
		print(f[3])
	elif a in [[f[0], f[3]], [f[3], f[5]], [f[5], f[2]], [f[2], f[0]]]:
		print(f[1])
	elif a in [[f[1], f[2]], [f[2], f[4]], [f[4], f[3]], [f[3], f[1]]]:
		print(f[0])
	elif a in [[f[1], f[3]], [f[3], f[4]], [f[4], f[2]], [f[2], f[1]]]:
		print(f[5])


Measured memory_bytes: 5612
import itertools
import functools

def inp():
  return list(map(int, input().split()))

N,C = inp()
D = [[0] * (C+1)]
c = [[], [], []]
for i in range(C):
  D.append([0] + inp())
for i in range(N):
  l = inp()
  for j in range(N):
    c[(i+j)%3].append(l[j])

# print(N,C,D,c)

sc = list(itertools.permutations(list(range(1,C+1)), 3))
# print(sc)

ret = []
for i in range(3):
  ret.append([])
  for j in range(1,C+1):    
    ret[-1].append(sum(list(map(lambda x: D[x][j], c[i]))))
#  print(ret[-1])

ans = []
for sc_i in sc:
  ans.append(0)
  for i in range(3):
    ans[-1] += ret[i][sc_i[i]-1]
#  print(ans[-1])

print(min(ans))

Measured memory_bytes: 8952
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 50) - 1;
int MOD = 1e9+7;
main(){
    ll N;
    cin >> N;
    ll mini = INF;
    for(ll i = 1;i * i <= N;i++){
        if(N % i != 0)continue;
        mini = min(mini, i - 1 + (N / i) - 1);
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<n+1;i++)
int main(){
  string s,m; cin>>s;
  int ans=0,n=s.size(),M;
  bool ok;
  for(int a=0;a<n;a++)for(int b=a+1;b<n+1;b++){
    m=s.substr(a,b-a);
    M=m.size();
    ok=true;
    for(int i=0;i<M;i++){
      
      if(m[i]!='A'&&m[i]!='T'&&m[i]!='G'&&m[i]!='C')ok=false;
    }
    if(ok)ans=max(ans,M);
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int n, G[110][110], d[110], f[110], c[110];
int t = 0;
 
void visit(int u){
    int i, j, v;
 
    c[u] = 1;
    d[u] = ++t;
   
    for(i = 1; i <= n; i++)
        if(G[u][i] == 1 && c[i] == 0) visit(i);
 
    c[u] = 2;
    f[u] = ++t; 
}
 
int main(){
    int i, j, k, u, v; 
 
    scanf("%d", &n);
   
    for(i = 1; i <= n; i++){
        c[i] = 0;
        for(j = 1; j <= n; j++){
            G[i][j] = 0;
        }
    }
   
    t = 0;
 
    for(i = 1; i <= n; i++){
        scanf("%d%d", &u, &k);

        for(j = 1; j <= k; j++){
            scanf("%d", &v);
            G[u][v] = 1;
        }
    }
   
  for(i = 1; i <= n; i++)
    if(c[i] == 0) visit(i);
   
  for(i = 1; i <= n; i++)
    printf("%d %d %d\n", i, d[i], f[i]);
   
  return 0;
}

Measured memory_bytes: 644
#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;
	int max1 = 0, max2;
	vector<int> A(N);
	rep(i, N) {
		int a;
		cin >> a;
		A.at(i) = a;
		if (max1 < 1) {
			max1 = a;
		}
		else if (a >= max1) {
			max2 = max1;
			max1 = a;
		}
		else if (a >= max2) {
			max2 = a;
		}
	}
	rep(i, N) {
		if (A.at(i) == max1) {
			cout << max2 << endl;
		}
		else {
			cout << max1 << endl;
		}
	}
	return 0;
}

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

int main()
{
    int t;
    cin >> t;
    std::vector<double> a(t);
    for(int i = 0; i < t; ++i)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    double ans = a[0];
    for(int i = 1; i < t; ++i)
    {
        ans = (a[i] + ans)/2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int a = sc.nextInt();
	int b = sc.nextInt();
        int c = sc.nextInt();
	boolean s = false;

       
	if(a==5){
	    if((b==5&&c==7)||(b==7&&c==5)){ 
		s = true;
	    }
	}else if(a==7){
       	    if(b==5&&c==5){
       		s = true;
	    }
	}
	if(s == true){
	    System.out.println("YES");
	    
	}else{
	    System.out.println("NO");
        }
		    
	
    }
}


Measured memory_bytes: 19796
// AOJ Volume 0 Problem 0012

#include <stdio.h>
#include <math.h>

typedef struct {
	double x1;
	double y1;
	double x2;
	double y2;
} LINE;


int cross(LINE *l1, LINE *l2)
{
	double ta, tb, tc, td;

//	ta=(x3-x4)*(y1-y3)+(y3-y4)*(x3-x1)
//	tb=(x3-x4)*(y2-y3)+(y3-y4)*(x3-x2)
//  tc=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3)
//  td=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4)

	ta = (l2->x1 - l2->x2) * (l1->y1 - l2->y1) + (l2->y1 - l2->y2) * (l2->x1 - l1->x1);
	tb = (l2->x1 - l2->x2) * (l1->y2 - l2->y1) + (l2->y1 - l2->y2) * (l2->x1 - l1->x2);
	tc = (l1->x1 - l1->x2) * (l2->y1 - l1->y1) + (l1->y1 - l1->y2) * (l1->x1 - l2->x1);
	td = (l1->x1 - l1->x2) * (l2->y2 - l1->y1) + (l1->y1 - l1->y2) * (l1->x1 - l2->x2);

	if ((ta * tb <= 0) && (tc * td <= 0)){
//		printf("[C]");
		return (1);
	}
//		printf("[X]");
	return (0);
}

int main(void)
{
	double xa, ya, xb, yb, xc, yc, xd, yd;
	double xg, yg;
	LINE a, b, c, x;
	int flag;
	int in_flag;
	
	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", 
			 	 &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF){

		flag = 0;
				
		xg = (xa + xb + xc) / 3.0;
		yg = (ya + yb + yc) / 3.0;
		
		a.x1 = xa;
		a.y1 = ya;
		a.x2 = xb;
		a.y2 = yb;

		b.x1 = xb;
		b.y1 = yb;
		b.x2 = xc;
		b.y2 = yc;

		c.x1 = xc;
		c.y1 = yc;
		c.x2 = xa;
		c.y2 = ya;

		x.x1 = xg;
		x.y1 = yg;
		x.x2 = xd;
		x.y2 = yd;

		in_flag =  cross(&a, &x);
		in_flag += cross(&b, &x);
		in_flag += cross(&c, &x);

		if (in_flag == 0){
			flag = 1;
		}
		
		xg = (xa + xb + xd) / 3.0;
		yg = (ya + yb + yd) / 3.0;

		a.x1 = xa;
		a.y1 = ya;
		a.x2 = xb;
		a.y2 = yb;

		b.x1 = xb;
		b.y1 = yb;
		b.x2 = xd;
		b.y2 = yd;

		c.x1 = xd;
		c.y1 = yd;
		c.x2 = xa;
		c.y2 = ya;

		x.x1 = xg;
		x.y1 = yg;
		x.x2 = xc;
		x.y2 = yc;

		in_flag =  cross(&a, &x);
		in_flag += cross(&b, &x);
		in_flag += cross(&c, &x);

		if (in_flag == 0){
			flag = 1;
		}

		xg = (xa + xc + xd) / 3.0;
		yg = (ya + yc + yd) / 3.0;

		a.x1 = xa;
		a.y1 = ya;
		a.x2 = xc;
		a.y2 = yc;

		b.x1 = xc;
		b.y1 = yc;
		b.x2 = xd;
		b.y2 = yd;

		c.x1 = xd;
		c.y1 = yd;
		c.x2 = xa;
		c.y2 = ya;

		x.x1 = xg;
		x.y1 = yg;
		x.x2 = xb;
		x.y2 = yb;

		in_flag =  cross(&a, &x);
		in_flag += cross(&b, &x);
		in_flag += cross(&c, &x);

		
		if (in_flag == 0){
			flag = 1;
		}

		xg = (xb + xc + xd) / 3.0;
		yg = (yb + yc + yd) / 3.0;

		a.x1 = xb;
		a.y1 = yb;
		a.x2 = xc;
		a.y2 = yc;

		b.x1 = xc;
		b.y1 = yc;
		b.x2 = xd;
		b.y2 = yd;

		c.x1 = xd;
		c.y1 = yd;
		c.x2 = xb;
		c.y2 = yb;

		x.x1 = xg;
		x.y1 = yg;
		x.x2 = xa;
		x.y2 = ya;

		in_flag =  cross(&a, &x);
		in_flag += cross(&b, &x);
		in_flag += cross(&c, &x);

		
		if (in_flag == 0){
			flag = 1;
		}

		if (flag == 1){
			printf("NO\n");
		}
		else {
			printf("YES\n");
		}
	}
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>

int n,m;
vector<IP> a;

int f(int x,int y,int z){

  vi v(n);

  rep(i,n){
    v[i]=a[i].F*x+a[i].S.F*y+a[i].S.S*z;
  }

  sort(all(v));
  reverse(all(v));

  int res=0;
  rep(i,m){
    res+=v[i];
  }
  return res;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  cin>>n>>m;
  a=vector<IP>(n);
  rep(i,n){
    cin>>a[i].F>>a[i].S.F>>a[i].S.S;
  }

  int ans=-INF;

  FOR(i,-1,2){
    FOR(j,-1,2){
      FOR(k,-1,2){
        if(i==0||j==0||k==0) continue;
        ans=max(ans,f(i,j,k));
      }
    }
  }


  cout<<ans<<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S seconnd
#define int ll

string s,t;
int a[30],b[30];

signed main(){
  cin>>s>>t;

  rep(i,s.size()){
    a[s[i]-'a']++;
    b[t[i]-'a']++;
  }

  sort(a,a+30);
  sort(b,b+30);

  rep(i,30){
    if(a[i]!=b[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }

  cout<<"Yes"<<endl;
}

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

void fnInput(int& rnPriceA, int& rnPriceB, int& rnPriceH, 
             int& rnNumA,   int& rnNumB)
{
  cin >> rnPriceA >> rnPriceB >> rnPriceH;
  cin >> rnNumA   >> rnNumB;
}

int fnMinCheck(int nPriceA, int nPriceB, int nPriceH, int nNumA, int nNumB)
{
  int nPriceMin;
  if      (nNumA < nNumB)
    nPriceMin = min( nPriceA * nNumA + nPriceB * nNumB,
                     min( (2 * nPriceH - nPriceB) * nNumA + nPriceB * nNumB,
                          2 * nPriceH * nNumB));
  else if (nNumA == nNumB)
    nPriceMin = min( (nPriceA + nPriceB) * nNumA, 2 * nPriceH * nNumA);
  else
    nPriceMin = min( nPriceA * nNumA + nPriceB * nNumB,
                     min( nPriceA * nNumA + (2 * nPriceH - nPriceA) * nNumB,
                          2 * nPriceH * nNumA));
  return nPriceMin;
}

int main()
{
  int nPriceA, nPriceB, nPriceH, nNumA, nNumB;
  
  fnInput(nPriceA, nPriceB, nPriceH, nNumA, nNumB);
  cout << fnMinCheck(nPriceA, nPriceB, nPriceH, nNumA, nNumB) << endl;

  return 0;
}

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

typedef long long ll;
using namespace std;

typedef long double ldouble;

const ll MXN = 2e5 + 1;

int n, a[MXN], b[MXN], sum;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + n + 1);
    sum = b[n / 2];
    for(int i = 1; i <= n; i ++){
        if(a[i] <= sum) cout << b[(n + 2) / 2] << '\n';
        else cout << b[(n + 1) / 2] << '\n';
    }
    return 0;
}


Measured memory_bytes: 3712
import math
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
p1 =0
for i in range(len(x)):
    p1 += abs(x[i]-y[i])
print(p1)
p2=0
for i in range(len(x)):
    p2 += (x[i]-y[i])**2
print(math.sqrt(p2))
p3=0
for i in range(len(x)):
    p3 += abs(x[i]-y[i])**3
print(math.pow(p3,1/3))
pinf=0
for i in range(len(x)):
    if abs(x[i]-y[i]) >= pinf:
        pinf = abs(x[i]-y[i])
print(pinf)


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

namespace ConsoleApp67
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            char[] Sletter = S.ToCharArray();
            bool same = true;
            for (int n = 0; n < S.Length-1; n++)
            {
                for(int m =0 ;m<S.Length  ; m++)
                { if (Sletter[n] == Sletter[m] && n != m)
                    {
                        same = false;
                        break;
                    }
                }
            }

            if (same == true)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
vector<int> t(111),u(111);
int n,x;
int main()
{
	cin >>n>>x;
	for(int i=0;i<n;i++)
	cin >>t[i];
	u[0]=0;
	for(int i=1;i<=n;i++)
	{
		u[i]=u[i-1]+t[i-1];
//		cout <<u[i]<<" ";
	}
	for(int i=0;i<=n;i++)
	if(u[i]>x)
	{
		cout <<i<<endl;
		return 0;
	}
	cout <<n+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

using namespace std;

class Usefull {
public:
	template<typename T>
	static void inputs(vector<T>& vec,int N) {
		string inputString;
		for (int i = 0; i < N; ++i) {
			T input;
			cin >> input;
			vec.push_back(input);
		}
	}
	static void hantei(bool b) {
		if (b) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
};

void Main()
{
	int N;
	cin >> N;
	int zoromecount = 0;
	bool zorome = false;
	for (int i = 0; i < N; ++i) {
		vector<int> saikoro;
		Usefull::inputs(saikoro, 2);
		if (saikoro[0] == saikoro[1]) {
			++zoromecount;
		}
		else {
			zoromecount = 0;
		}
		if (zoromecount >= 3) {
			zorome = true;
		}

		
	}
	Usefull::hantei(zorome);
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}




Measured memory_bytes: 3644
S=input()
alphabet=[chr(i) for i in range(ord('a'),ord('z')+1)]
if len(S)!=26:
    for x in alphabet: 
        if not(x in set(S)):
            flag=1
            break
    ans=S+x
    print(ans)
else:
    s=ord(S[25])
    j=25
    for i in range(24,-1,-1):
        if s<ord(S[i]):
            j=i
            s=ord(S[i])
        else:
            break

    if j==0:
        print(-1)
    else:
        l=S[j:]
        y=300
        for x in list(map(ord,l)):
            if ord(S[j-1])<x:
                y=min(y,x)
        ans=S[:j-1]+chr(y)
        print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using static System.Math;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split();
        int n = int.Parse(input[0]);
        int a = int.Parse(input[1]) - 1;
        int b = int.Parse(input[2]) - 1;
        int c = int.Parse(input[3]) - 1;
        int d = int.Parse(input[4]) - 1;
        string s = Console.ReadLine();
        int l = Min(a, b);
        int r = Max(c, d);
        for (int i = l; i < Min(r, n - 1); i++) //連続岩の排除
        {
            if (s[i] == '#' && s[i + 1] == '#')
            {
                Console.WriteLine("No");
                return;
            }
        }
        if (c < d)
        {
            Console.WriteLine("Yes");
            return;
        }
        bool f = false;
        for (int i = Max(a + 1, b); i <= Min(c - 1, d); i++)
        {
            if (s[i] == '#') continue;
            f = f || (s[i - 1] != '#' && s[i + 1] != '#');
        }
        Console.WriteLine(f ? "Yes" : "No");
    }
}

Measured memory_bytes: 13124
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define fi first
#define se second 
using namespace std;
//const LL INF = (LL) 1e9 + 5;
//const LL MOD = (LL) 1e9 + 7;
//const int MAXN = 200005;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	
	if (n % 2 == 1) {
		int l = 1, r = n;
		if (r % 2 == 0) r--; 
		for (int i = 0; i < m; i++) {
			cout << l << ' ' << r << '\n';
			l++;
			r--;
		}
	}
	else {
		int l = 1, r = n;
		vector<PII> ans;
		while (r - l > n / 2) {
			ans.push_back(PII(l, r));
			r--;
			l++;
		}
		while (r - l >= n / 2) r--;
		while ((r - l) % 2 == 1) r--;
		while (r - l > 0) {
			ans.push_back(PII(l, r));
			r--;
			l++;
		}
		for (int i = 0; i < m; i++) {
			cout << ans[i].fi << ' ' << ans[i].se << '\n';
		}
	}
		
	return 0;
}

Measured memory_bytes: 4256
n = input()

keta = len(n)

if keta%2 == 0:
    result = 0
    for i in range(keta-1):
        if i%2 == 1:
            pass
        else:
            result += 9*10**i
else:
    result = 0
    for i in range(keta - 2):
        if i % 2 == 1:
            pass
        else:
            result += 9 * 10 ** i
    result += int(n) - 10**(keta-1) + 1

print(result)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("YES");
	else say("NO");
}

int N;
const int MAX_V = 10000;
const int INF = 100000;
struct edge { int to, cap, rev; };
vector<edge> G[MAX_V]; //グラフの隣接リスト表現
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
	G[from].push_back({ to,cap,(int)G[to].size() });
	G[to].push_back({ from, 0, (int)G[from].size() - 1 });
}

int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	rep(G[v].size()) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	while (true) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INF);
		if (f == 0)return flow;
		flow += f;
	}
}

int main() {
	cin >> N;
	vi a(N), b(N), c(N), d(N);
	rep(N)cin >> a[i] >> b[i];
	rep(N)cin >> c[i] >> d[i];
	int s = 2 * N;
	int t = s + 1;
	rep(N) add_edge(s, i, 1);
	rep(N)add_edge(N + i, t, 1);
	For(i, N) {
		For(j, N) {
			if (a[i] < c[j] && b[i] < d[j])add_edge(i, N + j, 1);
		}
	}
	say(max_flow(s, t));
}
/*
	0～N-1を赤、N～2N-1を青の点として二部マッチング
*/

Measured memory_bytes: 640
#include <iostream>
using namespace std;;
int main()
{
	int i,k;
	while (1) {
		cin >> i>>k;
		if(i==0&&k==0){
		    break;
		}else if(i<k){
		    cout<<i<<' '<<k<<endl;
		    
		}else{
		    cout<<k<<' '<<i<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3052
def main():

    H, W = map(int, input().split())
    grid  = []
    for _ in range(H):
        grid.append(list(input()))

    # print(grid)
    white = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == ".":
                white += 1

    cur = [[0, 0]]
    goal = [H-1, W-1]
    turn = 0
    mv = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    reached = False
    grid[0][0] = "#"
    while cur and not reached:
        temp = []
        for i, j in cur:
            if [i, j] == goal:
                reached = True
                break
            for di, dj in mv:
                i1 = i + di
                j1 = j + dj
                if 0 <= i1 < H and 0 <= j1 < W and grid[i1][j1] == ".":
                    grid[i1][j1] = "#"
                    temp.append([i1, j1])
        if not reached:
            cur = temp
            turn += 1
    if not reached:
        return -1
    return  white - (turn+1)


if __name__ == '__main__':
    print(main())


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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 2020;
const ll INF = 1e17;
const double eps = 1e-12 , PI = acos(-1);

int n , m;

vi adj[N];
vi ans;

int start = 0;

int p[N];
bool vis[N];

void getCyc(int u){
    vi tmp;

    while( true ){
            tmp.push_back(u);
            if(u == start)break;
            u = p[u];
    }

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

    if((tmp.size() < ans.size()) || (ans.size() == 0))ans = tmp;
}

void bfs(int u){
    memset(vis , 0 , sizeof vis);

    queue < int > q;
    p[u] = u;
    vis[u] = 1;
    q.push(u);

    while( !q.empty() ){
            u = q.front();
            q.pop();

            for(int v : adj[u]){
                    if(v == start){
                            getCyc(u);
                            return;
                    }
            }

            for(int v : adj[u]){
                    if(vis[v])continue;
                    vis[v] = 1;
                    p[v] = u;
                    q.push(v);
            }
    }
}

void solve(int cs){
    scanf("%d %d" , &n , &m);

    for(int i = 0 ; i < m ; i ++){
            int u , v;
            scanf("%d %d" , &u , &v);
            adj[u].push_back(v);
    }

    for(int i = 1 ; i <= n ; i ++){
            start = i;
            bfs(i);
    }

    if(ans.size() == 0){
            printf("-1\n");
    }
    else {
            printf("%d\n" , ans.size());
            for(int A : ans){
                    printf("%d\n" , A);
            }
    }

}

main(){
    int t = 1;

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}



Measured memory_bytes: 384
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define REPV(i,a,b) for(int i = a; i>= b; --i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
#define INF 100000
#define ff first
#define ss second
const int M=1e9+7;


void solve()
{
	int k;
	cin>>k;
	if(k&1^1)
	cout<<"-1\n";
	else
	{
		int rem = 7 % k;
		int ans = 0;
		REP(i,1,(int)1e7)
		{
			if(!rem)
			{
				cout<<i<<"\n";
				return;
			}
			rem = (rem*10+7) % k;
		}
		cout<<"-1\n";
	}
}


int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}


Measured memory_bytes: 3652