akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <unordered_set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int gcd_ = std::gcd(A[0], A[1]);
  rep(i, N)
  {
    gcd_ = std::gcd(gcd_, A[i]);
  }

  if (gcd_ != 1)
  {
    cout << "not coprime" << endl;
    return 0;
  }

  int MX = 1000000;

  std::unordered_set<int> p;
  rep(i, N)
  {
    int tmp = A[i];
    vector<int> v;
    for (int j = 2; j * j <= A[i]; j++) {
      if (tmp % j == 0) {
        tmp /= j;
        if (p.find(j) != p.end())
        {
          cout << "setwise coprime" << endl;
          return 0;
        }
        else
        {
          v.emplace_back(j);
        }
      }
      if (tmp == 1) break;
    }
    
    if (tmp != 1) {
      if (p.find(tmp) != p.end())
        {
          cout << "setwise coprime" << endl;
          return 0;
        }

      v.emplace_back(tmp);
    }

    for (const auto e : v)
    {
      p.insert(e);
    }
  }

  cout << "pairwise coprime" << endl;

  return 0;
}


Measured memory_bytes: 7148
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int A=s.nextInt(),B=s.nextInt(),C=s.nextInt(),x=0,y=0,z=0;
		if(A==B)x++;if(B==C)y++;if(C==A)z++;
		System.out.println(x+y+z==1?"Yes":"No");
	}
}

Measured memory_bytes: 35764
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	vector<string> s(2);
	cin >> s[0] >> s[1];

	string xy;

	for (int i = 0; i < n;) {
		if (s[0][i]==s[1][i]) {
			xy.push_back('x');
			i++;
		}
		else {
			xy.push_back('y');
			i+=2;
		}
	}

	ll ans = 1;

	for (int i = 0; i < xy.size(); ++i) {
		if (i==0) {
			if (xy[i]=='x') ans *= 3;
			else ans *= 6;
		}
		else {
			if (xy[i]=='x') {
				if (xy[i-1]=='x') ans *= 2;
				else ans *= 1;
			}
			else {
				if (xy[i-1]=='x') ans *= 2;
				else ans *= 3;
			}
		}
		ans %= MOD;
	}

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

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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

long long gcd(long long a, long long b){
    if (a < b) swap(a, b);
    return b ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b){
    return a * b / gcd(a, b);
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

//--------------------------- Solve ---------------------------//

void solve() {
    int N, M; cin >> N >> M;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    long long lcm_ = v[0];
    long long half_lcm = lcm_ / 2;
    for (int i = 0; i < N; i++) {
        long long a = lcm_, b = v[i];
        long long c = b / 2 - half_lcm;
        if (c % gcd(a, b) != 0) {
            //cout << "flag1" << '\n';
            cout << 0 << '\n';
            return;
        }
        long long x, y;
        extGCD(a, b, x, y);
        x *= c / gcd(a, b);
        y *= c / gcd(a, b);
        //print(a, "*", x, "+", half_lcm, "=", b, "*", -y, "+", b / 2);

        half_lcm = a * x + half_lcm;
        while (half_lcm >= lcm(a, b)) half_lcm %= lcm(a, b);
        while (half_lcm < 0) {
            half_lcm %= lcm(a, b);
            half_lcm += lcm(a, b);
        }

        lcm_ = lcm(lcm_, v[i]);

        //print("half_lcm:", half_lcm, "lcm:", lcm_);

        if (half_lcm > M) {
            //cout << "flag2" << '\n';
            cout << 0 << '\n';
            return;
        }
    }

    //print("M:", M, "half_lcm:", half_lcm, "lcm:", lcm_);

    int ans = (M - half_lcm) / lcm_ + 1;
    
    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3768
#include <cstdio>
#include <algorithm>
using namespace std;
int cost[10][10];
int main() {
	int n;
	while(scanf("%d",&n),n) {
		for(int i=0;i<10;i++) {
			for(int j=0;j<10;j++) {
				cost[i][j]=cost[j][i]=(i==j)?0:(1<<27);
			}
		}
		int m=0;
		for(int i=0;i<n;i++) {
			int a,b,c;
			scanf("%d %d %d",&a,&b,&c);
			cost[a][b]=cost[b][a]=c;
			m=max(m,max(a,b));
		}
		for(int k=0;k<=m;k++) {
			for(int i=0;i<=m;i++) {
				for(int j=0;j<=m;j++) {
					cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
				}
			}
		}
		int A,B=(1<<27);
		for(int i=0;i<=m;i++) {
			int sum=0;
			for(int j=0;j<=m;j++) {
				sum+=cost[i][j];
			}
			if(B>sum)A=i,B=sum;
		}
		printf("%d %d\n",A,B);
	}
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <string.h>

#define LEN 100000

typedef struct p{
  char name[100];
  int ms;
  }P;

P Q[LEN+1];
void enqueue(P x);
P dequeue();
int head,tail,n;
int min(int a,int b){
  return a<b?a:b;
}

int main(){
  int c,i,q;
  int x=0;
  P u;
  scanf("%d %d",&n,&q);
  for (i=1;i<=n;i++){
    scanf("%s %d",Q[i].name,&Q[i].ms);
  }
  head=1;
  tail=n+1;
  while(head!=tail){
    u=dequeue();
    c=min(q, u.ms);
    u.ms-=c;
    x+=c;
    if(u.ms>0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name,x);
    }
  }
  return 0;
  }
  void enqueue(P x){
    Q[tail]=x;
    if (tail==LEN)tail=1;
    else tail++;
  }
  P dequeue(){
    P x=Q[head];
    if(head==LEN){
      head=1;
    }
    else head++;
    return x;
  }



Measured memory_bytes: 11836
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,k;
  string s;
  cin>>n>>k>>s;
  if(s[k-1]=='A')s[k-1]='a';
  if(s[k-1]=='B')s[k-1]='b';
  if(s[k-1]=='C')s[k-1]='c';
  cout<<s<<endl;
  
}

Measured memory_bytes: 256
a,b=map(int,input().split())
if a>1 and b>1:
    if a<b:
        print("Bob")
    elif a==b:
        print("Draw")
    else:
        print("Alice")
elif a==1 and b>1:
    print("Alice")
elif a>1 and b==1:
    print("Bob")
else:
    print("Draw")

Measured memory_bytes: 3060
N, M = map(int, input().split())

preds = {}
i = 1
for _ in range(M):
    x, y = input().split(' ')
    preds[i] = (int(x), int(y))
    i += 1


ans = [0 for x in range(M)]

flg = -1
num = 1
for x, y in sorted(preds.items(), key=lambda x: x[1]):
    if flg != y[0]:
        num = 1
        ans[x-1] = str(y[0]).rjust(6, '0') + str(num).rjust(6, '0')
        flg = y[0]
    else:
        num += 1
        ans[x-1] = str(y[0]).rjust(6, '0') + str(num).rjust(6, '0')

for i in ans:
    print(i)


Measured memory_bytes: 42128
#include<stdio.h>
#include<string.h>
#include<map>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int a[100];
	int t;
	int flag=0;
	for(int i=0;i<4;i++)
	{
		t=n%10;
		a[i]=t;
		n/=10;
	}
	if(a[0]==a[1]&&a[1]==a[2]||a[1]==a[2]&&a[2]==a[3])
	flag=1;
	if(flag)
	{
		printf("Yes\n");
	 } 
	 else
	 {
	 	puts("No");
	 }
	return 0;
}

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

#define rep(i, j) for(int i=0; i < (int)(j); i++)

template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }

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

    int N, K; cin >> N >> K;

    vector<vector<int>> sum_black(2 * K + 1, vector<int>(2 * K + 1));
    vector<vector<int>> sum_white(2 * K + 1, vector<int>(2 * K + 1));

    int init_ans = 0;
    int init_ans2 = 0;
    rep(i, N) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        x = x % (2 * K);
        y = y % (2 * K);
        (c == 'B' ? sum_black : sum_white)[y + 1][x + 1]++;
        bool in_black = (x < K and y < K) or (x >= K and y >= K);
        init_ans += (c == 'B' ? in_black : not in_black);
        init_ans2 += (c == 'W' ? in_black : not in_black);
    }
    rep(y, 2 * K + 1) {
        rep(x, 2 * K) {
            sum_black[y][x + 1] += sum_black[y][x];
            sum_white[y][x + 1] += sum_white[y][x];
        }
    }
    rep(y, 2 * K) {
        rep(x, 2 * K + 1) {
            sum_black[y + 1][x] += sum_black[y][x];
            sum_white[y + 1][x] += sum_white[y][x];
        }
    }    

    auto block_sum = [&] (vector<vector<int>> &sum, int sy, int sx, int ey, int ex) {
        int block1 = sum[ey][ex] - sum[ey][sx] - sum[sy][ex] + sum[sy][sx];
        sy = (sy + K) % (2 * K);
        ey = (ey + K) % (2 * K);
        sx = (sx + K) % (2 * K);
        ex = (ex + K) % (2 * K);
        if(ey == 0) ey = 2 * K;
        if(ex == 0) ex = 2 * K;
        int block2 = sum[ey][ex] - sum[ey][sx] - sum[sy][ex] + sum[sy][sx];
        return block1 + block2;
    };

    auto solve = [&] (vector<vector<int>> &sum_white, vector<vector<int>> &sum_black, int init_ans) {
        int ans = init_ans;
        rep(dy, K) {
            rep(dx, K) {
                int black_to_white = block_sum(sum_white, dy, 0, K, dx) + block_sum(sum_white, 0, dx, dy, K);
                black_to_white    -= block_sum(sum_black, dy, 0, K, dx) + block_sum(sum_black, 0, dx, dy, K);            
                int white_to_black = block_sum(sum_black, dy + K, 0, K + K, dx) + block_sum(sum_black, 0, dx + K, dy, K + K);
                white_to_black    -= block_sum(sum_white, dy + K, 0, K + K, dx) + block_sum(sum_white, 0, dx + K, dy, K + K);
                set_max(ans, init_ans + black_to_white + white_to_black);
            }
        }
        return ans;
    };    

    cout << max<int>(solve(sum_white, sum_black, init_ans), solve(sum_black, sum_white, init_ans2)) << endl;
    return 0;
}


Measured memory_bytes: 31744
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long N = nextLong();
        long K = nextLong();

        long a = N%K;
        a = Math.min(a, Math.abs(a-K));
        println(a);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> order(N);
  vector<int> satisfy(N);
  vector<int> additional(N-1);
  int sum = 0;
  
  for(int i=0; i<N; i++)
    cin >> order.at(i);
  for(int i=0; i<N; i++)
    cin >> satisfy.at(i);
  for(int i=0; i<N-1; i++)
    cin >> additional.at(i);
  
  for(int i=0; i<N; i++){
    int number = order.at(i)-1;
    sum += satisfy.at(number);
    
    
   if(i+1 < N){
     if(order.at(i) == order.at(i+1) - 1)
       sum += additional.at(number);
   }
    
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main(){
    int n; cin>>n;
    int ans=0;
    int ma = 0;
    for(int i = 0; i < n; i++){
        int t; cin>>t;
        ma = max(ma,t);
        if(t>=ma) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;

ll a,b,c,d,ans;
int main()
{
    cin>>a>>b>>c>>d;
    ans=max(max(a,b)*max(c,d),min(a,b)*min(c,d));
    ans=max(ans,max(a,b)*min(c,d));
    ans=max(ans,min(a,b)*max(c,d));
    cout<<ans<<endl;
    return 0;
}
////刷题！！！！！！！！！！！！！！！！


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

int niz[1000000];
int dp[100020];





int main()
{
   int n,k;
   cin>>n>>k;
   for(int i=0;i<n;i++)
   {
       cin>>niz[i];
   }
   dp[0]=0;
   for(int i=1;i<=n;i++)
   {
       int br=0;
       int minX=INT_MAX;
       for(int j=i-1;j>=0&&br<k;j--)
       {
            minX=min(minX,dp[j]+abs(niz[i]-niz[j]));
           br++;
       }
       dp[i]=minX;
   }
   cout<<dp[n-1];
    return 0;
}


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

cut=0
for i in range(1,N+1):
  if i >= 1 and i <= 9:
    cut =cut+ 1
  if i >= 100 and i <= 999:
    cut =cut+ 1
  if i >= 10000 and i <= 99999:
    cut =cut+ 1

print(cut)

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);   
    int N; cin >> N;
    map<pii, ll> dic;
    ll ans = 0;
    rep(i,N) {
        string S; cin >> S;
        int K = S.size();
        ll val = 0;
        rep(j,K) {
            if (S[j]=='.') continue;
            val *= 10;
            val += S[j] - '0';
        }
        int a = 0, b = 0, c = 0;
        bool flag = false;
        rep(j,K) {
            if (!flag) {
                if (S[j]=='.') flag = true;
            } else c++;
        }
        while (!(val&1)) {
            val >>= 1;
            a++;
        }
        while (val % 5 == 0) {
            val /= 5;
            b++;
        }
        a -= c;
        b -= c;
        for (auto j : dic) {
            auto[d,e] = j.first;
            if (a+d >= 0 and b+e >= 0) ans += j.second;
        }
        dic[pii(a,b)]++;
    }

    cout << ans << ln;
}


Measured memory_bytes: 3656
from collections import Counter


def solve(V):
    n = len(V)
    odd_max = Counter(V[1::2]).most_common(2)
    even_max = Counter(V[::2]).most_common(2)

    if odd_max[0][0] != even_max[0][0]:
        return n - odd_max[0][1] - even_max[0][1]
    elif  len(odd_max) == 1 and len(even_max) == 1:
        return n // 2
    elif len(odd_max) != 1 and len(even_max) == 1:
        return n - odd_max[1][1] - even_max[0][1]
    elif len(odd_max) == 1 and len(even_max) != 1:
        return n - odd_max[0][1] - even_max[1][1]
    else:
        return n - max(even_max[0][1] + odd_max[1][1],
                       even_max[1][1] + odd_max[0][1])

if __name__ == "__main__":
    n = int(input())
    l = input()
    print(solve(l.split(" ")))


Measured memory_bytes: 16800
#ifndef VS
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<math.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {
	cww() { CIN_ONLY{ ios::sync_with_stdio(false); cin.tie(0); } }
}star;
#define DEBUG if(0)
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r) { bool a = l>r; if (a)l = r; return a; }
template <typename T>inline bool chmax(T &l, T r) { bool a = l<r; if (a)l = r; return a; }
typedef vector<LL> V;
typedef vector<V> VV;
const LL INF = 1e14;
typedef pair<LL, int> P;
int main() {
	int m;
	while (cin >> m, m) {
		VV d(10, V(10, INF));
		REP(i, 10)d[i][i] = 0;
		V e(10, 0);
		REP(i, m) {
			int a, b;LL c;
			cin >> a >> b >> c;
			chmin(d[a][b], c);
			chmin(d[b][a], c);
			e[a] = e[b] = 1;
		}
		REP(k, 10)REP(i, 10)REP(j, 10)chmin(d[i][j], d[i][k] + d[k][j]);
		P ret(INF, 0);
		REP(i, 10)if (e[i]) {
			P ans(0,i);
			REP(j, 10)if (e[j])ans.first += d[i][j];
			chmin(ret, ans);
		}
		cout << ret.second << " " << ret.first << endl;
	}
}

Measured memory_bytes: 3128
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<double,double>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int n;cin>>n;int ans=0;
    int mini=1;
    rep(i,0,n){
        int a;cin>>a;
        ans+=(a-1)/mini;
        if(i==0||a==mini)mini++;
    }cout<<ans<<endl;
    return 0;
}

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

string k;
int n, d;
ll dp[10010][110][2];

ll F(int idx, int cursum, bool eq)
{
	if (idx == n)
		return (cursum == 0);
	if (dp[idx][cursum][eq] != -1)
		return dp[idx][cursum][eq];
	ll ans = 0;
	if (eq)
	{
		int dig = k[idx] - '0';
		for (int i = 0; i < dig; i++)
			ans = (ans + F(idx + 1, (cursum + i) % d, 0)) % MOD;
		ans = (ans + F(idx + 1, (cursum + dig) % d, 1)) % MOD;
	}
	else
	{
		for (int i = 0; i <= 9; ++i)
			ans = (ans + F(idx + 1, (cursum + i) % d, 0)) % MOD;
	}
	return (dp[idx][cursum][eq] = ans);
}

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

	cin >> k; cin >> d;
	n = k.length();
	memset(dp, -1, sizeof(dp));
	cout << ((F(0, 0, 1) - 1) % MOD + MOD) % MOD;

	return 0;
}

Measured memory_bytes: 21636
#include <stdio.h>

int main(void)
{
    int kisu_f=0,gusu_f=0,i;
    char s[200];

    scanf("%s",s);

    i=0;
    while(s[i] != '\0'){
        if(i%2 == 0){//奇数文字目
            //printf("i=%d, s[i] = %c\n",i,s[i]);
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
                kisu_f=1;
            }
        } else {//偶数文字目
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
                gusu_f=1;
            }
        }
        i++;
    }

    if(kisu_f == 0 && gusu_f == 0){
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

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

int main() {
  ll n, m, r = 0, g = 0, b = 0;
  string s;
  cin >> n >> s;

  for (int i = 0; i < n; i++) {
    if (s[i] == 'R')
      r++;
    else if (s[i] == 'G')
      g++;
    else
      b++;
  }
  m = r * g * b;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int k = j + j - i;
      if (k < n && s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
        m--;
        continue;
      }
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int n,tmp,left,pre;
	bool First;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		left = -1;
		First = true;

		for(int i = 0; i < n; i++){
			scanf("%d",&tmp);

			if(left == -1){
				left = tmp;
				if(i == n-1){
					if(First){
						printf("%d",tmp);
						First = false;
					}else{
						printf(" %d",tmp);
					}

				}
			}else{
				if(tmp - pre == 1){

					if(i == n-1){
						if(First){
							printf("%d-%d",left,tmp);
							First = false;
						}else{
							printf(" %d-%d",left,tmp);
						}
					}
				}else{

					if(left == pre){
						if(First){
							printf("%d",left);
							First = false;
						}else{
							printf(" %d",left);
						}
					}else{
						if(First){
							printf("%d-%d",left,pre);
							First = false;
						}else{
							printf(" %d-%d",left,pre);
							First = false;
						}
					}
					left = tmp;

					if(i == n-1){
						if(First){
							printf("%d",tmp);
							First = false;
						}else{
							printf(" %d",tmp);
						}
					}
				}
			}
			pre = tmp;
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 2656
#include<iostream>
#include<vector>

using namespace std;

const static int MAX_N = 100;
const static int INF = 100000000;

vector<int> a;
vector<int> b;
vector<int> c;

int N, M;

int dict[MAX_N][MAX_N];

int main() {
    cin >> N >> M;

    int ai, bi, ci;
    for (int i = 0; i < M; i++) {
        cin >> ai >> bi >> ci;
        a.push_back(ai - 1);
        b.push_back(bi - 1);
        c.push_back(ci);
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) {
                dict[i][j] = 0;
            } else {
                dict[i][j] = INF;
            }
        }
    }

    for (int i = 0; i < M; i++) {
        dict[a[i]][b[i]] = c[i];
        dict[b[i]][a[i]] = c[i];
    }


    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dict[i][j] = min(dict[i][j], dict[i][k] + dict[k][j]);
            }
        }
    }

    int ans = M;
    for (int i = 0; i < M; i++) {
        bool shortest = false;
        for (int j = 0; j < N; j++) {
            if (dict[j][a[i]] + c[i] == dict[j][b[i]]) 
                shortest = true;
        }
        if (shortest) 
            ans -= 1;
    }

    cout << ans << endl;


    
    return 0;
}


Measured memory_bytes: 256
import itertools
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


# プラスマイナスどっちにするかを8パターン全部試す

N, M = list(map(int, sys.stdin.buffer.readline().split()))
XYZ = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]
XYZ = np.array(XYZ, dtype=int)

ans = -INF
for sgn in itertools.product([-1, 1], repeat=3):
    H = np.dot(XYZ, sgn)
    H = np.msort(H)[::-1]
    ans = max(ans, H[:M].sum())
print(ans)


Measured memory_bytes: 12616
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 500010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define ull unsigned long long
#define mp make_pair
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, m;
int a[SIZE];
int main() {
	io(); cin >> n;
	rep(i, 1, n) cin >> a[i];
	int cnt = 1, pre = a[1];
	rep(i, 1, n) if (a[i] < pre) ++cnt, pre = a[i];
	cout << cnt;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

V<V<int>> accum;

int main() {
  // n = 都市の個数
  // m = 列車の数
  int n, m, query;
  cin >> n >> m >> query;

  accum = V<V<int>>(n + 1, V<int>(n + 1, 0));

  // build accum
  rep(i, m) {
    int l, r;
    cin >> l >> r;
    accum[l][r] += 1;
  }
  repf(i, 1, n + 1) {
    repf(j, 1, n + 1) {
      accum[i][j] += accum[i][j - 1] + accum[i - 1][j] - accum[i - 1][j - 1];
    }
  }

  rep(i, query) {
    int p, q;
    cin >> p >> q;
    int ans = accum[q][q] - accum[p - 1][q] - accum[q][p - 1] + accum[p - 1][p - 1];

    cout << ans << endl;
  }
}


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

int main() {
  string S;
  int res = 0;
  
  cin >> S;
  
  for(int i = 0;i< S.size()/2;i++){
	if(S.at(i) == S.at(S.size()-i-1)){
     // 
    }
    else{
      res++; 
    }
  }
  
  cout << res << endl;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n), B(n);
  map<pair<ll, ll>, ll> mp;
  ll zero=0, zeroA=0, zeroB=0;
  rep(i, n) {
    cin >> A[i] >> B[i];
    if(A[i] == 0 && B[i] == 0) {
      zero++;
    } else if(A[i] == 0) {
      zeroA++;
    } else if(B[i] == 0) {
      zeroB++;
    } else {
      ll g = gcd(abs(A[i]), abs(B[i]));
      A[i] /= g; B[i] /= g;
      if(A[i] < 0) {
        mp[{-A[i], -B[i]}]++;
      } else {
        mp[{A[i], B[i]}]++;
      }
    }
  }
  set<pair<ll, ll>> done;
  ll ans = 1;
  for(auto ele: mp) {
    ll a = ele.first.first;
    ll b = ele.first.second;
    if(!done.count({a, b})) {
      if(b > 0) {
        if(mp.count({b, -a}) && !done.count({b, -a})) {
          ll tmp = (modpow(2, ele.second) + modpow(2, mp[{b, -a}]) - 1) % mod;
          (ans *= tmp) %= mod;
          done.insert({a, b});
          done.insert({b, -a});
        } else {
          (ans *= modpow(2, ele.second)) %= mod;
          done.insert({a, b});
        }
      } else {
        if(mp.count({-b, a}) && !done.count({-b, a})) {
          ll tmp = (modpow(2, ele.second) + modpow(2, mp[{-b, a}]) - 1) % mod;
          (ans *= tmp) %= mod;
          done.insert({a, b});
          done.insert({-b, a});
        } else {
          (ans *= modpow(2, ele.second)) %= mod;
          done.insert({a, b});
        }
      }
    }
  }
  if(zeroA + zeroB > 0) {
    ll tmp = (modpow(2, zeroA) + modpow(2, zeroB) - 1) % mod;
    (ans *= tmp) %= mod;
  }
  (ans += zero) %= mod;
  cout << (ans+mod-1)%mod << endk;
  return 0;
}


Measured memory_bytes: 31440
#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const int Mod = 998244353;
const int MN = 100005, MS = 1 << 9;

inline void Add(int &x, int y) { x -= (x += y) >= Mod ? Mod : 0; }

int N, f1[MN], f2[MN], f3[MN];
std::vector<int> G1[MN], G2[MN], G3[MN];

inline void ReadGraph(std::vector<int> *G) {
	int M;
	scanf("%d", &M);
	while (M--) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x > y) std::swap(x, y);
		G[x].push_back(y);
	}
}
inline void SolveSG(std::vector<int> *G, int *f) {
	static int buk[MN];
	for (int i = N; i >= 1; --i) {
		for (int x : G[i]) buk[f[x]] = 1;
		f[i] = 0;
		while (buk[f[i]]) ++f[i];
		for (int x : G[i]) buk[f[x]] = 0;
	}
}

int pw[MN];
int b1[MS], b2[MS], b3[MS], Ans;

int main() {
	scanf("%d", &N);
	ReadGraph(G1);
	ReadGraph(G2);
	ReadGraph(G3);
	SolveSG(G1, f1);
	SolveSG(G2, f2);
	SolveSG(G3, f3);
	pw[0] = 1;
	for (int i = 1; i <= N; ++i) pw[i] = pw[i - 1] * 716070898ll % Mod;
	for (int i = 1; i <= N; ++i) Add(b1[f1[i]], pw[i]);
	for (int i = 1; i <= N; ++i) Add(b2[f2[i]], pw[i]);
	for (int i = 1; i <= N; ++i) Add(b3[f3[i]], pw[i]);
	for (int i = 0; i < MS; ++i)
		for (int j = 0; j < MS; ++j)
			Ans = (Ans + (LL)b1[i] * b2[j] % Mod * b3[i ^ j]) % Mod;
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
int main()
{
    IOS;
 
    ll n,a=0,b=0,c=0,d=0;
    cin>>n;
    
    for(ll i=0;i<n;i++){
        string x;
        cin>>x;
        if(x=="AC"){
            a++;
        }
        if(x=="WA"){
            b++;
        }
        if(x=="TLE"){
            c++;
        }
        if(x=="RE"){
            d++;
        }
    }
    
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<b<<"\n";
    cout<<"TLE x "<<c<<"\n";
    cout<<"RE x "<<d<<"\n";
        
    return 0;
}




Measured memory_bytes: 3644
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>

using namespace std;

#define ll long long

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

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

#define inRange(x, a, b) (a <= x && x <= b)
#define between(x, a, b) (a < x && x < b)

template<typename T> void swap(T &a, T &b){
	T temp = a;
	a = b;
	b = temp;
}

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void input(vector<T> &vec, int n){
	T temp;
	For(i, n){
		cin >> temp;
		vec.push_back(temp);
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
	Vec(int _x, int _y):
	x(_x), y(_y){}
};

template<typename T> void print(T *x, int n){
	For(i, n){
		cout << x[i] << " ";
	}
	cout << endl;
}

template<typename T> void print(vector<T> &x){
	For(i, (int)x.size()){
		cout << x[i] << " ";
	}
	cout << endl;
}

int gcd(int n, int m){
	if(n % m == 0){
		return m;
	}
	else{
		return gcd(m, n % m);
	}
}

template<typename T> T binarySearch(vector<T> a, T target){
	int cur = (int)a.size() / 2;
	int upper = (int)a.size() - 1;
	int buttom = 0;
	while(1){
		if(a[cur] == target){
			return a[cur];
		}
		else if(a[cur] > target){
			upper = cur;
			cur = (buttom + cur) / 2;
		}
		else{
			buttom = cur;
			cur = (cur + upper) / 2;
		}
	}
}

template<typename T> T binarySearch(vector<T> a, T func(T), T target){
	int cur = (int)a.size() / 2;
	int upper = (int)a.size() - 1;
	int buttom = 0;
	while(1){
		int value = func(a[cur]);
		if(value == target){
			return a[cur];
		}
		else if(value > target){
			upper = cur;
			cur = (buttom + cur) / 2;
		}
		else{
			buttom = cur;
			cur = (cur + upper) / 2;
		}
	}
}

template<typename T>
class UnionFind{
public:
	vector<set<T>> unit_unit;
	int getUnionNumber(T elm){
		for(int i = 0; i < (int)unit_unit.size(); i++){
			int number = unit_unit[i].find();
			if(number !=unit_unit[i].end()){
				return i;
			}
		}
		return -1;
	}

	void mergeUnion(int baseUnitNum, int absorvedUnitNum){

	}
};

int main(){

	int n, k;
	string s;
	cin >> n >> k >> s;
 
 	k--;
	if(s[k] == 'A')s[k] = 'a';
	if(s[k] == 'B')s[k] = 'b';
	if(s[k] == 'C')s[k] = 'c';
 
	out(s);
 
	return 0;

	return 0;

}

Measured memory_bytes: 256
from sys import stdin


def main():
    read = stdin.read
    N, Q = map(int, input().split())
    S = input().strip()
    LR = [int(x) - 1 for x in  read().split()]
    AC = []
    pre = None
    cnt = 0
    for c in S:
        if c == "A":
            pre = "A"
        elif pre == "A" and c == "C":
            cnt += 1
            pre = None
        elif pre == "A":
            pre = None
        AC.append(cnt)
    for l, r in zip(*[iter(LR)] * 2):
        print(AC[r] - AC[l])
    return


main()


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

int main(){
  int n, m, a, b;
  cin >> n >> m;
  vector<int> count(n, 0);
  for(int i=0;i<m;i++){
    cin >> a >> b;
    count[a-1]++;
    count[b-1]++;
  }
  for(int i=0;i<n;i++){
    cout << count[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
matrix = [list(input()) for j in range(H)]
A = []
for line in range(H):
    if matrix[line].count('.') != W:
        A.append(matrix[line])
B = [] # extract rows
for row in range(W):
    flg = True
    for line in range(len(A)):
        if A[line][row] == '#':
            flg = False
    if flg == True:
        B.append(row)
C = [] # answer
for line in range(len(A)):
    for b in sorted(B, reverse=True):
        A[line].pop(b)
    C.append(A[line])
for c in C:
    print(''.join(c))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    string s;
    cin >> s;
    
    for(int i = 0; i <= s.size(); i++){
        if(i % 2 == 1){
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        } else{
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
def length(xa, ya, xb, yb)
  Math.sqrt((xa - xb)**2 + (ya - yb)**2)
end

n = gets.to_i
while gets
  xa, ya, ra, xb, yb, rb = $_.split(' ').map(&:to_f)
  l = length(xa, ya, xb, yb)
  if ra > l + rb
    out = 2
  elsif rb > l + ra
    out = -2
  elsif ra + rb < l
    out = 0
  else
    out = 1
  end
  puts out
end

Measured memory_bytes: 6132
import java.util.*;
public class Main {
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String input = sc.nextLine();
      String[] inputs = input.split(" ");
      
      int n = Integer.parseInt(inputs[0]);
      int r = Integer.parseInt(inputs[1]);
      
      if(n >= 10){
        System.out.println(r);
      }else{
        int num = 100 * (10-n);
        System.out.println(r+num);
      }
    }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys
import math

def solve(N: int, K: int):
    p = 0
    for i in range(1, N+1):
        if i < K:
            kaisu = math.ceil(math.log2(K / i))
            p += (1 / N) * (0.5) ** kaisu
        else:
            p += (1 / N)
    print(p)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
    int n,f[200005]= {0};
    cin>>n;
    if (n%2==0)
    {
        for (int i=0; i<=n-1; ++i)
            if (i%2==0)
                cin>>f[100002+i/2];
            else cin>>f[100002-i/2-1];
        for (int i=100002-(n-1)/2-1; i<=100002+(n-2)/2; ++i)
            cout<<f[i]<<" ";
    }
    else
    {
        for (int i=0; i<=n-1; ++i)
            if (i%2==0)
                cin>>f[100002-i/2];
            else cin>>f[100002+i/2+1];
        for (int i=100002-(n-1)/2; i<=100002+n/2; ++i)
            cout<<f[i]<<" ";
    }
}


Measured memory_bytes: 2944
s = input()
t = input()

x = 0
y = 0

answer = 0

for i in range(0,len(s) - len(t) + 1):
    count = 0
    for j in range(0, len(t)):
        if s[i+j] == t[j]:
            count += 1
    answer = max(count, answer)

print(len(t) - answer)



Measured memory_bytes: 9096
# -*- coding: utf-8 -*-
import numpy as np

n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
x = np.array(a)
y = list(np.argsort(x)[1::])
#print(y)
y = map(str, y)
#print(y)
print(" ".join(y))

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

using P = pair<long long, long long>;
long long r, c;
vector<long long> p, q;
priority_queue<P, vector<P>, greater<P>> pq;

long long solve();

int main() {
  cin >> r >> c;
  p.resize(r);
  q.resize(c);
  for (auto &x : p) cin >> x;
  for (auto &x : q) cin >> x;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0, cnt[2] = {c + 1, r + 1};
  for (auto x : p) pq.push(P(x, 0));
  for (auto x : q) pq.push(P(x, 1));
  while (pq.size()) {
    P now = pq.top();
    pq.pop();
    res += now.first * cnt[now.second];
    --cnt[1 - now.second];
  }
  return res;
}

Measured memory_bytes: 8048
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

static bool can_make(const vector<int>& a, const int len, const int cut) {
    auto total = 0LL;
    for (auto ai : a) {
        auto x = (ai + len -1) / len;
        total += (x - 1);
    }
    return total <= cut;
}

int main()
{
    int n, k;
    cin >> n >> k;
    auto a = vector<int>(n);
    for (auto& a_i : a)
        cin >> a_i;
    sort(a.begin(), a.end());

    auto L = 0;
    auto R = a.back() + 1;
    while (L + 1 < R) {
        auto M = L + (R-L)/2;
        if (can_make(a, M, k))
            R = M;
        else
            L = M;
    }
    cout << R << endl;
    return 0;
}


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

def cal(a,b,c):
    return(a**2+b**2+c**2 + a*b+b*c+c*a)

memo = [0]*(10**4)

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            temp = cal(i,j,k)
            if temp <= 10**4:
                memo[temp-1] += 1
for i in memo[:N]:
    print(i)

Measured memory_bytes: 69580
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define pb push_back;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1000000007;
const ll LLINF = 1000000000000000007LL;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s, t;
    cin >> s >> t;
    cout << t+s << endl;
    
    return 0;
}

Measured memory_bytes: 256
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

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

#define F first
#define S second
#define pb push_back
#define SZ(x) (int)(x.size())
#define all(x) x.begin(),x.end()
 
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
 
const ll maxn=2e2+10, mod=1e9+21, inf=1e18;

ll n;
char ed[maxn][maxn];

deque<ll> q;
ll dis[maxn];

int main(){
	
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) cin>>ed[i][j];

	ll ans=-inf;
	bool F=1;
	for(int i=1;i<=n;i++){
		memset(dis,69,sizeof(dis));
		q.pb(i), dis[i]=0;
		while(SZ(q)){
			ll v=q.back(); q.pop_back();
			for(int u=1;u<=n;u++) if(ed[v][u]=='1'){
				if(dis[v]==dis[u]) F=0;
				else if(dis[v]+1<dis[u]){
					dis[u]=dis[v]+1;
					q.push_front(u);
				}
			}
		}
		ans=max(ans,*max_element(dis+1,dis+1+n)+1);
	}

	if(F) cout<<ans<<endl;
	else cout<<-1<<endl;

	return 0;
}



















Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int ll;

const ll MAX_N = 100000;

int main () {
    ll n, m;
    ll A[MAX_N] = {0};

    cin >> n >> m;

    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    sort(A, A + n);
    ll tmp;
    bool flag = true;

    while (m > 0 && flag) {
        A[n - 1] /= 2;
        m--;
        if (m == 0) {
            flag = false;
            break;
        }
        for (int i = n - 2; i >= 0; i--) {
            if (A[i] < A[n -1]) {
                break;
            }
            A[i] /= 2;
            m--;
            if (m == 0) {
                flag = false;
                break;
            }
        }
        if (!flag) {
            break;
        }
        sort(A, A + n);
    }

    ll sum = 0;

    for (int i = 0; i < n; i++) {
        sum += A[i];
    }

    cout << sum << endl;
}


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

using namespace std;
#define mx 200000
#define ll long long
vector<pair<int,int> >v[mx+2];
int ans[mx+2];
void dfs(int u,int p,int k){

    int x=1;
    if(k==1)x=2;
    for(int i=0;i<v[u].size();i++){

        int x1=v[u][i].first;
        if(x1==p){
            continue;
        }
        ans[v[u][i].second] = x;
        dfs(x1,u,x);
        x++;
        if(x==k)x++;

    }
}
int main(){

    int n;

    cin>>n;

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

        int x,y;
        scanf("%d%d",&x,&y);
        v[x].push_back(make_pair(y,i));
        v[y].push_back(make_pair(x,i));
    }


    dfs(1,0,0);
    int ans1 =0;

    for(int i=1;i<=n;i++)ans1=max(ans1,(int)v[i].size());


    dfs(1,0,0);
    printf("%d\n",ans1);
    for(int i=1;i<n;i++)printf("%d\n",ans[i]);


  return 0;
}


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

int main() {
  int x,y;
  cin >> x >> y;
  int count = 0;
  if (x == 1 && y ==1){
    count += 400000;
  }
  if(x == 1){
    count += 300000;
  }
  if(x == 2){
    count += 200000;
  }
  if(x == 3){
    count += 100000;
  }
  if(y == 1){
    count += 300000;
  }
  if(y == 2){
    count += 200000;
  }
  if(y == 3){
    count += 100000;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		LinkedList<Integer> points = new LinkedList<Integer>();
		LinkedList<Integer> dist = new LinkedList<Integer>();

		// input
		int num = scan.nextInt();
		int pointsNum = scan.nextInt();
		for(int i = 0; i < pointsNum; i++){
			points.add(scan.nextInt());
		}

		// sort
		Collections.sort(points, Comparator.reverseOrder());

		// check dist
		for(int i = 0; i < pointsNum - 1; i++){
			dist.add(points.poll() - points.peek());
		}

		// sort
		Collections.sort(dist, Comparator.reverseOrder());

		for(int i = 0; i < num - 1; i++){
			dist.poll();
		}

		// check answer
		int answer = 0;
		while(dist.size() > 0){
			answer += dist.poll();
		}

		System.out.println(answer);

	}
}



Measured memory_bytes: 64780
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int k;
int s[3000 + 1][3000 + 1];

void add(int x, int y, char c)
{
    if (c == 'W') y += k;
    int cx = x % (2 * k);
    int cy = y % (2 * k);

    if ((IN(0, k, cy) && IN(0, k, cx)) || (IN(k, 2 * k, cy) && IN(k, 2 * k, cx)))
    {
        int dx[] = {0, 2 * k, k,     0, 2 * k};
        int dy[] = {0,     0, k, 2 * k, 2 * k};
        cx = cx % k;
        cy = cy % k;
        rep (i, 5)
        {
            ++s[cy + dy[i] + 1][cx + dx[i] + 1];
        }
    }
    else
    {
        int dx[] = {k, 0, 2 * k,     k};
        int dy[] = {0, k,     k, 2 * k};
        cx = cx % k;
        cy = cy % k;
        rep (i, 4)
        {
            ++s[cy + dy[i] + 1][cx + dx[i] + 1];
        }
    }
}

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

    int n;
    cin >> n >> k;

    int x, y;
    char c;
    rep (i, n)
    {
        cin >> x >> y >> c;
        add(x, y, c);
    }

    rep (i, 3 * k) rep (j, 3 * k) s[i + 1][j + 1] += s[i + 1][j] + s[i][j + 1] - s[i][j];

    int ans = 0;
    rep (i, 2 * k + 1)
    {
        rep (j, 2 * k + 1)
        {
            int num = s[i + k][j + k] - s[i + k][j] - s[i][j + k] + s[i][j];
            ans = MAX(ans, num);
        }
    }

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



Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] s = new int[13];
		int[] h = new int[13];
		int[] c = new int[13];
		int[] d = new int[13];

		for(int i = 0; i < 13; i++) {
			s[i] = 1;
			h[i] = 1;
			c[i] = 1;
			d[i] = 1;
		}

		String[] deleteMark = new String[n];
		int[] deleteRank = new int[n];

		for(int i = 0; i < n; i++) {
			deleteMark[i] = sc.next();
			deleteRank[i] = sc.nextInt();
		}

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

			switch (deleteMark[i]) {

			case ("S"):
				s[deleteRank[i]-1] = 0;
			break;

			case ("H"):
				h[deleteRank[i]-1] = 0;
			break;

			case ("C"):
				c[deleteRank[i]-1] = 0;
			break;

			case ("D"):
				d[deleteRank[i]-1] = 0;
			break;

			}

		}

		for(int i = 0; i < 13; i++) {

			if(s[i] == 1) System.out.println("S " + (i+1));

		}

		for(int i = 0; i < 13; i++) {

			if(h[i] == 1) System.out.println("H " + (i+1));

		}

		for(int i = 0; i < 13; i++) {

			if(c[i] == 1) System.out.println("C " + (i+1));

		}

		for(int i = 0; i < 13; i++) {

			if(d[i] == 1) System.out.println("D " + (i+1));

		}

	}

}





Measured memory_bytes: 26304
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    if (a > 8) {
        cout << ":(" << endl;
        return 0;
    }
    if (b > 8) {
        cout << ":(" << endl;
        return 0;
    }

    cout << "Yay!" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int N,num=1;
  cin>>N;
  while(1){
    if(num*2<=N)
      num=num*2;
    else break;
  }
  cout<<num<<endl;
  return 0;
}



Measured memory_bytes: 3108