akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
  int a,b,c,x,count=0,total=0;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&x);

  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        total=i*500+j*100+k*50;
        if(total==x) count++;
      } 
    }
  }

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


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	int x, n;
	cin >> x >> n;
	vi wys(102);
	rep(i, 0, n) {
		int p;
		cin >> p;
		wys[p] = 1;
	}
	int best = 0;
	rep(i,1,102) {
		if (wys[i]) {
			continue;
		}
		int dist = abs(i - x);
		if (dist < abs(best - x)) {
			best = i;
		}
	}
	cout << best << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int a,b,c;cin >> a >> b >> c;
  if(a == b && b == c && a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
    cout << -1 << endl;
  }else if( a % 2 == 1 or b % 2 == 1 or c%2 == 1){
    cout << 0 << endl;
  }else{
    int count2 = 0;
    while( a%2 == 0 && b%2 == 0 && c%2 == 0){
      count2++; a /= 2;b/=2;c/=2;
    }
    if(a%2 == 0 || b%2 == 0 || c%2 == 0){
    }else{
      count2++;
    }
    cout << count2 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
typedef long long LL;
typedef pair<int,int> pii;

const LL MOD = 1e9+7;

void run_case() {
    LL n, k;
    LL ans = 0;
    cin >> n >> k;
    for(LL i = k; i <= n+1; ++i) {
        LL t1 = i*(i-1)/2;
        LL t2 = (2*n+1-i)*i/2;
        ans = (ans + t2 - t1 + 1) % MOD;
        ans = (ans + MOD) % MOD;
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(10);
    run_case();
    cout.flush();
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int n;
	while (std::cin >> n && n) {
		std::vector<int> p;

		for (int i = 0; i < n; i++) {
			int a; std::cin >> a;
			p.push_back(a);
		}

		std::sort(p.begin(), p.end());

		int sum = 0;
		for (int i = 1; i < p.size() - 1; i++) {
			sum += p[i];
		}

		std::cout << (sum / (n - 2)) << std::endl;
	}
}


Measured memory_bytes: 3072
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAtCoderBeginnerContest999 solver = new AAtCoderBeginnerContest999();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAtCoderBeginnerContest999 {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            out.println(in.string().replace('9', '.').replace('1', '9').replace('.', '1'));
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 24788
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

int x,a,b;

void solve(){
  cin >> x >> a >> b;
  int c=abs(x-a),d=abs(x-b);
  if(c>d)cout << "B";
  else cout << "A";
  cout << endl;
}

int main() {
  solve();
  return 0;
}


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

const ll MOD = 1e9+7;

int main() {
    ll n;
    cin >> n;
    ll s = 0, ans = 0;
    rep(i,n) {
        ll a;
        cin >> a;
        ans += a*s;
        s += a;
        s %= MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<long long> v;
    for(int i = 0; i < n; i++) {
        long long d = a[i] / b[i];
        if(a[i] % b[i] != 0) {
            d++;
        }
        v.push_back(d * b[i] - a[i]);
    }
    for(int i = n - 1; i > 0; i--) {
        if(v[i] > v[i-1]) {
            long long d = (v[i] - v[i-1]) / b[i-1];
            if((v[i] - v[i-1]) % b[i-1] != 0) {
                d++;
            }
            v[i-1] += d * b[i-1];
        }
    }
    cout << v[0] << "\n";
}

Measured memory_bytes: 5820
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
    vector<ll> a(21,0);
    ll L;cin>>L;
    ll num=L-1;//0~numの数を表現する最後に-1足せよおい
    ll tmp=num;
    ll v=0;
    tmp++;
    while(tmp>0){
        tmp/=2;v++;
    }
    /*必要点数v
    v点あるとき
    0~(2^(v-1)-1)の数を表現できる
     */


    vector<tuple<ll,ll,ll>> ans;

    //頂点i->i+1に0と2^(i-1)の重みの辺を張る
    for(int i=1;i<v;i++){
        ans.push_back(make_tuple(i,i+1,0));
        ans.push_back(make_tuple(i,i+1,(ll)pow(2,i-1)));
    }

    //今表現できている数は0~(2^(v-1)-1)
    ll now=(ll)pow(2,v-1)-1;
    //これから作るのはnow+1~num
    for(int i=v-1;i>0;i--){
        ll p=(ll)pow(2,i-1)-1;
        if(now+1+p<=num){
            ans.push_back(make_tuple(i,v,now+1));
            now+=p+1;
        }
    }

    cout<<v<<' '<<ans.size()<<endl;
    for(auto x:ans){
        cout<<get<0>(x)<<' '<<get<1>(x)<<' '<<get<2>(x)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,y,ans,ic,uc,hc;
int main(){
    cin>>n>>y;


    for(int i=0;i<n+1;i++){
        if(1000*i>y||i>n)break;
        for(int u=0;u<n+1;u++){
            if(1000*i+5000*u>y||i+u>n)break;
            for(int h=0;h<n+1;h++){
                if(1000*i+5000*u+10000*h>y||i+u+h>n)break;
                if(1000*i+5000*u+10000*h==y&&i+u+h==n){
                    ic=h;
                    uc=u;
                    hc=i;
                    ans=1;
                    break;
                }
            }if(ans)break;
        }if(ans)break;
    }

    for(int i=0;i<1000000000;i++){
        int aho;
      aho++;
      for(int i=0;i<10;i++){
        int ghj;
      }
    }








    if(ans==1){
        cout<<ic<<" "<<uc<<" "<<hc<<endl;
    }else{
        cout<<"-1 -1 -1"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n;cin>>n;
  string s;cin>>s;
  vector<int> v_b(n+1);
  int cnt_b = 0;
  v_b[0] = cnt_b;
  for(int i=1;i<=n;++i){
    auto sub = s.substr(i-1,1);
    if (sub == "#") {
      ++cnt_b;
    }
    v_b[i] = cnt_b;
  }
  int cnt_w=0;
  vector<int> v_w(n+1);
  v_w[n] = cnt_w;
  for(int i=n-1;i>=0;--i){
    auto sub = s.substr(i,1);
    if (sub == ".") {
      ++cnt_w;
    }
    v_w[i] = cnt_w;
  }
  int out = n;
  for(int i=0;i<n+1;++i){
    out = min(out, v_b[i] + v_w[i]);
  }
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 2180
// atcoder 175

//A
/*
#include <iostream>
using namespace std;
#define ll  long long
#define M 1000000007
#define tc int t; cin>>t; while(t--)
#include <cstring>
int main(){
	string s;
	cin>>s;
	int l = 0, maxL = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'R' && maxL <= l){
			l++;
			maxL = l; 
		}
		else if(s[i] == 'S'){
			l = 0; 
		}
	}
	cout << maxL << endl;
	return 0;
}
*/

// B
#include <iostream>
using namespace std;
#define ll  long long
#define M 1000000007
#define tc int t; cin>>t; while(t--)
#include <cstring>

ll triangle(ll arr[], int n){
	ll ans = 0;

	for(int  i = 1; i <= n-2; i++){
		for(int j = i+1; j <= n-1; j++){
			for(int k = j+1; k <= n; k++){
				bool a = arr[i] != arr[j] && arr[j] != arr[k] && arr[i] != arr[k];
				bool b = arr[i] + arr[j] > arr[k] && arr[j] + arr[k] > arr[i] && arr[i] + arr[k] > arr[j];
				if( a && b){
					ans++;
				}
			}
		}
	}
	return ans;
}
int main(){
	int n;
	cin>>n;
	ll arr[n];
	for(int i = 1; i <= n; i++){
		cin>>arr[i];
	}
	cout << triangle(arr , n) << endl;
}


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

#define readFile freopen("in.txt","r",stdin)
#define writeFile freopen("out.txt","w",stdout)
#define fastIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

const int N = 100010;
int n,arr[500];

int main() {
#ifndef ONLINE_JUDGE
//    readFile; // be aware 
#endif
    fastIO;
    cin >> n;
    n *= 2;
    for(int i = 0; i < n; i++) cin >> arr[i];
    sort(arr,arr+n);
    int res = 0;
    for(int i = 0; i < n; i+= 2) res += min(arr[i],arr[i+1]);
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000"]

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>

#define fr first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
//#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

using namespace std;

#ifdef __LOCAL
#define dbg(x) cerr << #x << " : " << x << '\n'
const int maxn = 100;
#else
#define dbg(x)
    const int maxn = 2e5 + 100;
#endif

//tg: @galebickosikasa

const ll inf = (ll) 2e9;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll) 1e9 + 7;
const ll ns = 97;
const int MAXLOG = 20;
const int N = 45;

#define int ll

random_device rd;
mt19937 SuperRandom(rd());

int binpow (int a, int n, int m) {
    if (n == 0) return 1;
    if (n % 2) return (a * binpow(a, n - 1, m)) % m;
    int b = binpow(a, n / 2, m);
    return (b * b) % m;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    int n, p;
    string s;
    cin >> n >> p >> s;
    hm <int, int> kek;
    kek[0] = 1;
    int ans = 0, t = 0;
    if (p != 2 && p != 5) {
        for (int i = n - 1; i >= 0; --i) {
            int cnt = n - i - 1;
            t += (s[i] - '0') * binpow((10), cnt, p);
            t %= p;
            dbg (t);
            ans += kek[t];
            ++kek[t];
        }
    } else {
        for (int i = 0; i < n; ++i) {
            t *= 10;
            t += s[i] - '0';
            t %= p;
            if (t == 0) {
                ans += i + 1;
            }
        }
    }

    cout << ans;




};


Measured memory_bytes: 916
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

s = 1
g = 0
i = 1
history = [s]
flag = [False] * n
flag[0] = True

while True:
    g = a[s-1]
    if flag[g-1] == True:
        break
    else:
        flag[g-1] = True
        history.append(g)
        s = g
        i += 1


x = history.index(g)

if k < i:
    ans = history[k]
else:
    d = (k-x) % (i - x)

    ans = history[x + d]

print(ans)


Measured memory_bytes: 32380
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int n;
    int i = 0;
    int j = 0;
    cin >> n;
    int a[n];

    int ans = 0;

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

    for (i=0; i<n; i++){
        for (j=i+1; j<n; j++){
            ans = ans + a[i] * a[j];
        }
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N,L = list(map(int, input().split()))

total = 0
min_abs = 114514
eat = 0
for i in range(1,N+1):
    taste = L+i-1
    total += taste
    if abs(taste) < min_abs:
        min_abs = abs(taste)
        eat = taste

total -= eat
print(total)

Measured memory_bytes: 3060
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        Arrays.sort(c);
        int count =1;
        boolean ans = true;
        for(int i =1;i<c.length;i++){
            if(c[i-1]!=c[i]){
                if(count%2!=0){
                    ans = false;
                    break;
                }
            }
            count ++;
        }
        if(count%2!=0){
            ans = false;
        }
        if(ans){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef unsigned long long int ullint;
std::string YesNo[] = {"No","Yes"};
#define loop(i,N) for(int i=0; i<(N); i++)
template<typename T>
auto sort_all(T& v) { return std::sort(v.begin(),v.end()); }
template<typename T>
auto sum_all(const T& v) { auto z = v[0]; z = 0;
    return std::accumulate(v.begin(),v.end(),z); }
template<typename T>
auto input(int N) {
    std::vector<T> v(N);
    loop(i,N) std::cin >> v[i];
    return std::move(v);
}
class range {
    typedef int Int;
    Int start, stop, step;

    void initialize() {
        auto sign = (step >= 0) ? 1 : -1;
        stop = start + ((stop-start-sign)/step + 1) * step;
        if ((stop-start) * step <= 0) stop = start;
    }
public:
    range(Int start, Int stop, Int step=1) : start(start), stop(stop), step(step) {
        initialize();
    }
    range(Int stop) : start(0), stop(stop), step(1) { initialize(); }

    struct iterator {
        Int i, step;
        Int& operator*() { return i; }
        iterator& operator++() { i += step; return *this; }
        bool operator!=(const iterator& v) { return i != v.i; }
    };
    iterator begin() { return {start, step}; }
    iterator end()   { return {stop, step}; }
};

typedef llint Int;

int main(void)
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int AB = C*2;
    if (AB >= A + B) {
        cout << A*X + B*Y << endl;
    } else if (X < Y) {
        auto d = Y - X;
        if (AB < B) {
            cout << AB*Y << endl;
        } else {
            cout << AB*X + B*d << endl;
        }
    } else {
        auto d = X - Y;
        if (AB < A) {
            cout << X*C << endl;
        } else {
            cout << AB*Y + A*d << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DIM 57
#define modulo 1000000007
using namespace std;

struct matrix
{
    long long n,a[DIM][DIM];
    
    void mul(matrix b)
    {
        matrix am = *this;
        for(int i = 1; i <= n; ++i)
            for(int j = 1; j <= n; ++j)
            {
                a[i][j] = 0;
                for(int k = 1; k <= n; ++k)
                    a[i][j] = (a[i][j]+am.a[i][k]*b.a[k][j])%modulo;
            }
    }
    
    void power(long long k)
    {
        matrix c = (*this);
        k--;
        while(k)
        {
            if(k&1) mul(c);
            c.mul(c);
            k>>=1;
        }
    }
};


int main()
{
    matrix a;
    long long k;
    cin>>a.n>>k;
    for(int i = 1; i <= a.n; ++i)
        for(int j = 1; j <= a.n; ++j)
            cin>>a.a[i][j];
            
    a.power(k);
    long long res = 0;
    for(int i = 1; i <= a.n; ++i)
    for(int j = 1; j <= a.n; ++j)
    {res+=a.a[i][j];
    res%=modulo;}
    
    cout<<res;
    
    
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),M[]=new int[n+1];
		
		for(int i=0;i<=n;i++) {
			if(i==0) {
				M[i++]=in.nextInt();
				M[i]=in.nextInt();
			}
			else {
				in.nextInt();
				M[i]=in.nextInt();
			}
		}
		
		int DP[][]=new int [n+1][n+1];
		for(int i=1;i<=n;i++) {
			for(int j=1;i+j<=n;j++)DP[j][i+j]=Integer.MAX_VALUE;
		}
		
		
		for(int i=1;i<n;i++) {
			for(int j=1;i+j<=n;j++) {
				if(i==1) {
					DP[j][i+j]=M[j-1]*M[j]*M[i+j];
					continue;
				}
				for(int k=j;k<i+j;k++) {
					int v=DP[j][k]+DP[k+1][i+j]+(M[j-1]*M[k]*M[i+j]);
					DP[j][i+j]=Math.min(DP[j][i+j], v);
				}
			}
		}
		System.out.println(DP[1][n]);
	}

}



Measured memory_bytes: 26684
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	s := next()
	if s[2] == s[3] && s[4] == s[5] {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] input = br.readLine().split(" ");

        System.out.println((Integer.parseInt(input[0]) + Integer.parseInt(input[1])) / 2);
    }
} 


Measured memory_bytes: 24432
#include <bits/stdc++.h>
#include <iterator>
#include <tuple>
using namespace std;
using ll = long long;

int main()
{
  int n;
  cin >> n;
  vector<int> l(2 * n);
  for (auto &e : l)
    cin >> e;
  sort(begin(l), end(l));
  int sum = 0;
  for (int i = 0; i < 2 * n; ++i)
  {
    if (i % 2 == 0)
      sum += l[i];
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	ArrayList<Integer>[] g;
	int[] parent;
	int[] height;
	int[][] lca;

	void dfs(int cur, int par) {
		parent[cur] = par;
		for (int dst : g[cur]) {
			if (dst == par)
				continue;
			height[dst] = height[cur] + 1;
			dfs(dst, cur);
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean[][] connected = new boolean[N][N];
		int[][] edge_index = new int[N][N];
		lca = new int[N][N];
		ArrayList<Integer> list = new ArrayList<>();
		for (int i = 0; i < N; ++i)
			for (int j = 0; j < N; ++j) {
				lca[i][j] = -1;
				edge_index[i][j] = -1;
			}
		g = new ArrayList[N];
		parent = new int[N];
		height = new int[N];
		int[] A = new int[N - 1];
		int[] B = new int[N - 1];
		Arrays.fill(parent, -1);
		for (int i = 0; i < N; ++i)
			g[i] = new ArrayList<Integer>();
		for (int i = 0; i < N - 1; ++i) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			--a;
			--b;
			g[a].add(b);
			g[b].add(a);
			A[i] = a;
			B[i] = b;
			connected[a][b] = true;
			connected[b][a] = true;
			edge_index[a][b] = i;
			edge_index[b][a] = i;
		}
		dfs(0, -1);
		{
			for (int u = 0; u < N; ++u) {
				for (int v = 0; v < N; ++v) {
					int curu = u;
					int curv = v;
					while (curu != curv) {
						if (height[curu] < height[curv]) {
							curu ^= curv;
							curv ^= curu;
							curu ^= curv;
						}
						curu = parent[curu];
					}
					lca[u][v] = curu;
				}
			}
			for (int h = N; h >= 0; --h) {
				for (int i = 0; i < N; ++i) {
					if (height[i] == h) {
						list.add(i);
					}
				}
			}
		}
		int M = sc.nextInt();
		int[] u = new int[M];
		int[] v = new int[M];
		for (int i = 0; i < M; ++i) {
			u[i] = sc.nextInt();
			v[i] = sc.nextInt();
			--u[i];
			--v[i];
		}
		long ans = 0;
		for (int s = 0; s < (1 << M); ++s) {
			int[] w = new int[N];
			for (int shift = 0; shift < M; ++shift) {
				if ((s >> shift) % 2 == 0)
					continue;
				int common = lca[u[shift]][v[shift]];
				w[u[shift]]++;
				w[v[shift]]++;
				w[common]--;
				w[common]--;
			}
			int ng = 0;
			for(int i=0;i<list.size();++i) {
				int cur=list.get(i);
				if(cur==0)continue;
				w[parent[cur]]+=w[cur];
				if(w[cur]>0) {
					++ng;
				}
			}
			int ok=N-1-ng;
			ans += (Integer.bitCount(s) % 2 == 0 ? 1 : -1) * (1L << ok);
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 91120
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

const int dev = 1e9+7;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    ll T;
    cin >> T;
    vector<ll> As(N);
    for (int i=0;i<N;i++){
        cin >> As[i];
    }

    ll res = 0;
    ll mini = As[0];
    ll maxDiff = 0;
    for (int i=1;i<N;i++){
        if(maxDiff < As[i] - mini){
            maxDiff = As[i]-mini;
            res = 0;
        }
        if(maxDiff == As[i] - mini){
            res++;
        }
        mini = min(As[i], mini);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

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

    cin >> a >> b >> c >> d;

    if ((abs(a - b) <= d && abs(b - c) <= d) || (abs(a-c) <= d))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

int margin(int k){
    int m = (k+9)/10 * 10;
    return m - k;
}

int main(){
    vector<int> dish(5);
    int m = 0;
    int idx = 0;
    rep(i, 0, 5){
        cin >> dish.at(i);
        if (margin(dish.at(i)) > m){
            idx = i;
            m = margin(dish[i]);
        }
    }
    // sort(dish.begin(), dish.end());
    int time = 0;
    for (int i = 0; i < 5; i++){
        if (i == idx) continue;
        time += (dish[i]+9)/10 * 10;
    }
    cout << time + dish[idx] << endl;
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int cnt[200005];
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; cin >> n;
	map<int, int> cnt;
	ll ans = 0;

	rep(i, 1, n + 1) {
		int t; cin >> t;
		if (i - t >= 0) ans += cnt[i - t];
		if (t + i <= n) cnt[t + i]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11732
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

    if( (a < c && c < b ) || (b < c && c < a) ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
def main() :
    N = int(input())
    # N = float(input())

    # 式変形していいかんじに下ごしらえして、
    # 2変数分のループで全探索する。O(3500^2)なら間に合うはず。

    # for h in range(1,3501) :
    for h in range(1,3500) :
        # 組み合わせでみればいいので1からじゃなくてよい
        for n in range(h,3501) :
            bo = 4*h*n - N*n - N*h
            if (bo == 0) :
                continue

            omega = (N * h * n) / bo * 1.0
            if (omega > 0 and omega.is_integer() == True) :
                print(h,n,int(omega))
                return

main()

Measured memory_bytes: 3060
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); cin >> a;
  each(x, a) --x;
  vector<ll> ans;
  rrep(i, n) {
    ll pos = -1;
    rrep(j, a.size()) {
      if (a[j] == j) {
        pos = j;
        break;
      }
    }
    if (pos < 0) {
      cout << -1 << endl;
      return;
    }
    ans.pb(pos);
    a.erase(a.begin()+pos);
  }
  reverse(all(ans));
  each(x, ans) cout << x+1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        scan.close();

        int[] num = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

        System.out.println(num[k-1]);
    }
}

Measured memory_bytes: 21332
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      int[] dp = new int[n+1];
      dp[0] = 0;
      for(int i=1; i<=n; i++) {
        dp[i] = Integer.MAX_VALUE;
        
        for(int pow = 1; pow <= i; pow *= 6) {
          dp[i] = Math.min(dp[i], dp[i-pow]+1);
        }

        for(int pow = 9; pow <= i; pow *= 9) {
          dp[i] = Math.min(dp[i], dp[i-pow]+1);
        }
      }

      System.out.println(dp[n]);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

int main() {
    int n; cin >> n;
    int maxr = 0;
    int minp = 1e9;
    for (int i=0; i<n; ++i) {
        int a, b; cin >> a >> b;
        maxr = max(maxr, a);
        minp = min(minp, b);
    }
    cout << maxr + minp << endl;
}

Measured memory_bytes: 256
while 1:
    try:
        x,y,xx,yy,l,ll=map(float,input().split(','))
        p=complex(x,y)
        pp=complex(xx,yy)
        lp=complex(l,ll)
        lp-=p
        a=pp-p
        b=a*lp.conjugate()/a.conjugate()+p
        print(b.real,b.imag)
    except:break

Measured memory_bytes: 7444
#include "bits/stdc++.h"
using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	map<int,int> even,odd; //mapで各数列での要素の出現数を記録する
	for(int i = 0; i < n; i++){
		if(i%2==0) odd[v[i]]++;
		else even[v[i]]++;
	}

	int even_1=0,even_2=0,odd_1=0,odd_2=0;
	int e1=0,e2=0,o1=0,o2=0;
	int cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			even_1 = itr->first;
		}
	}
	e1 = cnt;
	cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt && itr->first != even_1){
			cnt = itr->second;
			even_2 = itr->first;
		}
	}
	e2 = cnt;

	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			odd_1 = itr->first;
		}
	}
	o1= cnt;
	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt && itr->first != odd_1){
			cnt = itr->second;
			odd_2 = itr->first;
		}
	}
	o2=cnt;

	if(even_1 == odd_1){
		cout << min(n-e1-o2, n-e2-o1) << endl;
	}else{
		cout << n-e1-o1 << endl;
	}

	return 0;
}

Measured memory_bytes: 5376
fn main() {
    proconio::input! {
        s: proconio::marker::Chars,
    }
    let mut m = std::collections::HashMap::new();
    for c in s {
        *m.entry(c).or_insert(0) += 1;
    }
    let ans = if m.values().all(|x| x % 2 == 0) {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 2100
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

template<typename InputIt>
void PRINT_RANGE(InputIt first, InputIt last)
{
    for(; first != last; ++first)
        cout << *first << (first==last ? "" : " ");
    cout << "\n";
}

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

#define DEBUG
#undef DEBUG

using ll  = long long;
using ull = unsigned long long;

int H, W;
int N;
int A[10001];

int M[100][100]; // [y][x]

void coord_next(int& x, int& y, bool& fwd)
{
    if(x == 0 && !fwd) {
        ++y;
        fwd ^= 1;
    }
    else if(x == W-1 && fwd) {
        ++y;
        fwd ^= 1;
    }
    else {
        int dx = fwd ? 1 : -1;
        x += dx;
    }
}

void solve()
{
    bool fwd = true; // 右へ進むか?
    int x = 0;
    int y = 0;

    FOR(color, 1, N+1) {
        REP(_, A[color]) {
            //cout << x << " " << y << " " << color << "\n";
            M[y][x] = color;
            coord_next(x, y, fwd);
        }
    }

    REP(y, H) {
        REP(x, W) {
            cout << M[y][x] << (x==W-1 ? "" : " ");
        }
        cout << "\n";
    }
}

int main()
{
    cin >> H >> W;
    cin >> N;
    FOR(i, 1, N+1) {
        cin >> A[i];
        //cout << A[i] << " ";
    }

    solve();

    return 0;
}


Measured memory_bytes: 384
N = int(input())
L = list(map(int, input().split()))
#入力される数値には０が入っていることがあり、その場合積は当然０になる
result = 1
hantei = True
zero = False
if 0 in L:
    zero = True
else:
    for i in L:
        result *= i
        if result > 10**18:
            hantei = False
            break
if zero:
    print(0)
elif hantei:
    print(result)
else:
    print("-1")

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())
#define UNIQUE(v) \
    SORT(v);      \
    v.resize(distance(v.begin(), unique(v.begin(), v.end())))

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF DBL_MAX
// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    string s;
    cin >> s;
    if (s.back() != 's')
        s.push_back('s');
    else {
        s.push_back('e');
        s.push_back('s');
    }
    cout << s << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }

// #ifdef DEBUG
//     for (int t = 1; t <= tt || cin.rdbuf()->in_avail(); t++) {
//         // cout << "Case #" << t << ": ";
//         solve();
//     }
// #else
//     for (int t = 1; t <= tt; t++) {
//         // cout << "Case #" << t << ": ";
//         solve();
//     }
// #endif

    return 0;
}

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

lli n, m;

int main(void){
	cin >> n >> m;
	vector<bool> p(n+1), q(n+1);
	rep(i, m){
		lli a, b;
		cin >> a >> b;
		if(a == 1) p[b] = true;
		if(b == n) q[a] = true;
	}
	for(int i = 2; i <= n-1; i++){
		if(p[i] == true && q[i] == true){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 3576
n,m=map(int,input().split())
*a,=map(int,input().split())
a.sort()
d=[a[i+1]-a[i] for i in range(m-1)]
d=sorted(d,reverse=True)
if m<=n:
	print(0)
else:
	print(sum(d[(n-1):]))

Measured memory_bytes: 13968
from copy import deepcopy
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(a)
a1 = deepcopy(a)
for i in range(1, n):
    cur = x * i
    a2 = deepcopy(a1)
    for j in range(n):
        a1[n - j - 1] = min(a2[n - j - 1], a[n - i - j - 1])
        cur += a1[n - j - 1]
    ans = min(ans, cur)
print(ans)

Measured memory_bytes: 77980
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

void distance(vector<int>& x,vector<int>& y,int &n,int p){
  double d;
  for(int i =0; i <n; i++){
    d+=pow(fabs(x.at(i)-y.at(i)),p);
  }
  d=pow(d,(1.0/p));
  cout << std::fixed << std::setprecision(6) << d<< endl;
}
void cheb(vector<int>& x,vector<int>& y,int &n){
  double d=0;
  for(int i =0; i <n; i++){
    double a =fabs(x.at(i)-y.at(i));
    if(d<a){
      d=a;
    }
  }
  cout << std::fixed << std::setprecision(6) << d<< endl;
}

int main() {
  int n;
  cin >>n;
  vector<int> x(n);
  vector<int> y(n);
  
  for(int i = 0; i < n; i++){
    cin >> x.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> y.at(i);
  }
  
  distance(x,y,n,1);
  distance(x,y,n,2);
  distance(x,y,n,3);
  cheb(x,y,n);
}


Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 200 + 7;
int d[N][N];
string s[N];
int n;
VI g[N];
char u[N];

void dfs(int v, char x)
{
	u[v] = x;
	for(auto i: g[v])
	{
		if (u[i] == 0)
			dfs(i, 3 - x);
		if (u[i] == u[v])
		{
			cout << -1;
			exit(0);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	cin >> n;
	FOR(i, 0, n)
		cin >> s[i];
	
	FOR(i, 0, n)
		FOR(j, 0, n)
			if (i != j)
				d[i][j] = INF;
	
	FOR(i, 0, n)
		FOR(j, 0, n)
			if (s[i][j] == '1')
				g[i].PB(j), d[i][j] = 1;
	
	dfs(0, 1);
	FOR(k, 0, n)
		FOR(i, 0, n)
			FOR(j, 0, n)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	
	int mx = 0;
	FOR(i, 0, n)
		FOR(j, 0, n)
			mx = max(mx, d[i][j]);
			
	cout << mx + 1 << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)

int dx[4]={1, -1, 0, 0};
int dy[4]={0, 0, 1, -1};

int main(void) {
    int n, t, keta;
    t = 0;
    cin >> n;
    keta=n;
    while(keta>0){
        t += keta % 10;
        keta /= 10;
    }

    if(n%t==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
using namespace std;
typedef long long ll ;
const long long N = 1e5,OO=0x3f3f3f3f;
ll n,weight,w[105],v[105];
ll dp[105][1000000];
ll solve(int i,int val)
{
    if(i==n){
        if(val==0)
        return 0;
        return 1e18;
    }
    ll &ret=dp[i][val];
    if(~ret)
        return ret;

    ret=solve(i+1,val);
    ret=min(ret,w[i]+solve(i+1,val-v[i]));
    return ret;

}
int main()
{
    cin>>n>>weight;
    for(int i=0; i<n; i++)
        cin>>w[i]>>v[i];
    memset(dp,-1,sizeof dp);
    for(int i=1e5;i>=0; i--)
    {
        ll ans=solve(0,i);

        if(ans<=weight)
        {
            cout<<i<<"\n";break;

        }
    }

}


Measured memory_bytes: 824672
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(ll i=a; i<= b; ++i)
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
typedef long long ll;

int main(){
    optimize();
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll x,n;
        cin>>x>>n;
        unordered_set<ll> st;
        FOR(i,0,n-1)
        {
            ll xx;
            cin>>xx;
            st.insert(xx);
        }
        if(st.find(x) == st.end())
        {
            cout<<x<<endl;
            return 0;
        }
        ll i=1;
        ll j=1;
        while(1)
        {
            ll b=x-i;
            ll a=x+j;
            if(st.find(a)!=st.end() && st.find(b)!=st.end())
            {
                i++;
                j++;
            }
            else if(st.find(b)==st.end())
            {
                cout<<b<<endl;
                return 0;
            }
            else if(st.find(a)==st.end())
            {
                cout<<a<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3620
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
import fractions
#from scipy.misc import comb

N = int(input())
A = list(map(int, input().split()))

m = A[0]
for a in A:
    m = (m*a)//fractions.gcd(m,a)

ans = 0
for a in A:
    ans += (m-1)%a

print(ans)

Measured memory_bytes: 13324
<?php
fscanf(STDIN, "%d", $n);
$kuku = array();
$judge = 0;
for($i = 1; $i < 10; $i++) {
    for($j = 1; $j < 10; $j++) {
        $kuku[$i][$j] = $i * $j;
    }
}
for($i = 1; $i < 10; $i++) {
    for($j = 1; $j < 10; $j++) {
        if($n === $kuku[$i][$j]) {
            $judge = 1;
        }
    }
}
if($judge === 1) {
    echo "Yes";
} else {
    echo "No";
}

Measured memory_bytes: 4728
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::string S;

int main() {
  std::cin >> N >> S;

  bool fl = N % 2 == 0;

  rep( i, N/2 )
    fl &= S[i] == S[i+N/2];

  std::cout << (fl ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3636
m, n= gets.split(' ').map(&:to_i)
arr = Array.new(2).map{[]}

m.times { arr[0] << gets.split(' ').map(&:to_i) }
n.times { arr[1] << gets.to_i }

arr[0].each do |e|
  num = 0
  e.each_with_index { |i, j| num += i * arr[1][j] }
  puts num
end

Measured memory_bytes: 8820
import math
import bisect
import heapq
from collections import deque

n, m = map(int, input().split())

p = [[0] * n for _ in range(n)]

c, d = [0] * m, [0] * m
for i in range(m):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    c[i],d[i] = a,b

    p[a][b], p[b][a] = 1, 1


def dfs(p):
    seen = [False] * n
    s = 0
    deq = deque([0])
    while deq:
        s = deq.pop()
        seen[s] = True
        for i in range(n):
            if p[s][i] == 0 or seen[i]:
                continue
            deq.append(i)

    for i in range(n):
        if not seen[i]:
            return 1
    return 0


ans = 0

for i in range(m):
    a,b = c[i],d[i]
    p[a][b], p[b][a] = 0, 0

    ans += dfs(p)
    p[a][b], p[b][a] = 1, 1

print(ans)


Measured memory_bytes: 3420
#include <ctime>
#include <iomanip>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <list>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

#define int long long
#define INF 1e18
#define EPS 1e-9
#define NIL -1
#define N 100

int gcd(int x, int y) {
    if(y == 0) return x;
    int z = max(x, y) % min(x, y);
    return gcd(min(x, y), z);
}

signed main() {
    int n; cin >> n;
    vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i];

    int t_gcd = a[0];
    for(int i = 1; i < n; i++) t_gcd = gcd(t_gcd, a[i]);

    cout << t_gcd << endl;
}


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

d=[[int(_) for _ in input().split()] for i in range(n)]

d=[d_[0]==d_[1] for d_ in d]


c=0
for i in d:
    if i:
        c+=1
        if c>=3:
            print("Yes")
            exit()
    else:
        c=0
print("No")

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

using namespace std;

int main() {
	string s; cin >> s;
	int i;
	for (i = 0; i < 19; i++) {
		if (s[i] == ',') {
			s[i] = ' ';
		}
	}

	cout << s;
	return 0;
}

Measured memory_bytes: 256