akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        boolean judge1 = (a==b&&b!=c)||(a==c&&a!=b)||(b==c&&a!=b);
        boolean judge2 = !(a==b && b==c);
        if(judge1 && judge2)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------


int main(int argc,char** argv){ fastio; myio;
  int n;
  cin>>n;
  ll y;
  cin>>y;
  ll a=10000ll,b=5000ll,c=1000ll;
  int lp1 = y/a;
  rep(i,lp1+1){
    ll res1 = y - a*i;
    int lp2 = res1/b;
    rep(j,lp2+1){
      ll res2 = res1 - b*j;
      int  k = res2/c;
      if( i+j+k == n ){ 
        cout<<i<<" "<<j<<" "<<k<<endl; 
        return 0; 
      }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1;
}

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

struct UnionFind {
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
    }

    int ans = 0;
    rep(i, n) ans = max(ans, uf.size(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4012
from collections import defaultdict


def longest_common_subsequence(s, t):
    dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])
    return dp[-1][-1]


def longest_common_subsequence2(s, t):
    dp = [0] * (len(t) + 1)
    for i in range(len(s)):
        si = s[i]
        tmp = dp[:]
        for j in range(len(t)):
            if si == t[j]:
                dp[j + 1] = tmp[j] + 1
            elif dp[j + 1] < dp[j]:
                dp[j + 1] = dp[j]
    return dp[-1]


def main():
    n = int(input())
    for _ in range(n):
        X, Y = input(), input()
        print(longest_common_subsequence2(X, Y))


if __name__ == '__main__':
    main()

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

int main(){
	int h,w;
	cin >> h >> w;
	char field[10][10];
	rep(i,h){
		rep(j,w){
			cin >> field[i][j];
		}
	}
	int count = 0;
	rep(i,h){
		rep(j,w){
			if(field[i][j] == '#') count++;
		}
	}
	if(count == w+h-1){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n; cin >> n;
		vector<double> v(n);
		rep (i, n) {
			cin >> v[i];
		}
		sort(all(v));
		double ans = v[0];
		for (int i = 1; i < n; ++i) {
			ans = (v[i] + ans) / 2;
		}
		printf("%.6f\n", ans);
    return;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n; cin >> n;
	if (n % 2)
		cout << 0;
	else {
		ll ans = 0;
		for (ll i = 1; i < 26; i++) {
			ans += (ll)(n / (ll)(pow(5, i) * 2));
		}
		cout << ans;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int W;
    int H;
    int x;
    int y;
    int r;
    
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if (0<=x-r && x+r<=W && 0<=y-r && y+r<=H) {
        printf("Yes\n");
    }
    if (0>x-r || x+r>W || 0>y-r || y+r>H) {
        printf("No\n");
    }
    
    
    return 0;
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define PI 3.1415926535897932384626
#define mod 1000000007
#define fo(i,n) for(i=0;i<n;i++)
#define endl "\n"
#define mset(m,v) memset(m,v,sizeof(m))
typedef vector<int>	vi;

void solve()
{
	int n,i,r=0,w=0,x=0,ans;
	cin >> n ;
	string s;
	cin >> s;
	for(i=0;i<n;i++){
	    if(s[i]=='R')r++;
	}
	w=n-r;
	if(r<w){
	    for(i=0;i<r;i++){
	        if(s[i]=='R')x++;
	    }
	    ans=r-x;
	}
	else {
	    for(i=1;i<=w;i++){
	        if(s[n-i]=='W')x++;
	    }
	    ans=w-x;
	}
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long double w,h,x,y;
  cin >> w >> h >> x >> y;
  long double u=w*h/2;
  if(w/2==x&&h/2==y)cout << u << " " << 1 << endl;
  else cout << u << " " << 0 << endl;
}  


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
int main(){
    string a,b,ans;
    cin>>a>>b;
    ans=a+b;
    long long aa=stoll(ans);
    long long j=sqrt(aa);
    if(aa==j*j){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h = read::<usize>();
    let w = read::<usize>();
    let mut field = vec![];
    for _ in 0..h {
        field.push(read::<String>());
    }
    for _ in 0..w + 2 {
        print!("#");
    }
    println!("");
    for y in 0..h {
        println!("#{}#", field[y]);
    }
    for _ in 0..w + 2 {
        print!("#");
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#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--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

ll dp[105][4][4][4];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  rep(i,4){
      rep(j,4){
          rep(k,4){
              if((i== 0 && j == 2 && k == 1 ) || (i == 0 && j == 1 && k == 2 ) || (i == 2 && j == 0 && k ==1))continue;
              dp[3][i][j][k] = 1;
          }
      }
  }
  FOR(i,3,n+1){
      rep(j,4){
          if(j==1){
              rep(k,4){
                  rep(l,4){
                      rep(m,4){
                          if(((k==0||l==0) && m == 2) || (l==2 && m == 0) || (k==0 && l ==2))continue;
                          dp[i][l][m][j] += dp[i-1][k][l][m];
                          dp[i][l][m][j] %= MOD;
                      }
                  }
              }
          }else if(j==2){
              rep(k,4){
                  rep(l,4){
                      rep(m,4){
                          if(l==0 && m==1)continue;
                          dp[i][l][m][j] += dp[i-1][k][l][m];
                          dp[i][l][m][j] %= MOD;
                      }
                  }
              }
          }else{
              rep(k,4){
                  rep(l,4){
                      rep(m,4){
                          dp[i][l][m][j] += dp[i-1][k][l][m];
                          dp[i][l][m][j] %= MOD;
                      }
                  }
              }
          }
      }
  }
  ll ans = 0;
  rep(i,4){
      rep(j,4){
          rep(k,4){
          ans += dp[n][i][j][k];
          ans %= MOD;
          }
      }
  }
  
  cout << ans << endl;

}

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

typedef long long ll;

ll dp[310][90010];
int N, A[310];
ll mod = 998244353;
ll ans = 0;
int sum;

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

    ans = 1;
    for(int i = 0; i < N; i++)ans = ans * 3 % mod;

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j <= 90000; j++)
        {
            dp[i + 1][j] += 2 * dp[i][j];
            dp[i + 1][j] %= mod;
            dp[i + 1][j + A[i]] += dp[i][j];
            dp[i + 1][j + A[i]] %= mod;
        }
    }

    for(int i = (sum + 1) / 2; i <= 90000; i++)
    {
        ans += 3 * (mod - dp[N][i]);
        ans %= mod;
    }

    if(sum % 2 == 0)
    {
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j <= 90000; j++)
            {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= mod;
                dp[i + 1][j + A[i]] += dp[i][j];
                dp[i + 1][j + A[i]] %= mod;
            }
        }

        ans += 3 * dp[N][sum / 2];
        ans %= mod;
    }


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


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

using namespace std;

int main()
{
    vector<int> side(4);
    
    cin >> side[0] >> side[1] >> side[2] >> side[3];
    sort(side.begin(), side.end());
    
    if( (side[0] == side[1]) && (side[2] == side[3]) )
    {
        cout << "yes" << endl;
    }
    else
    {
        cout << "no" << endl;
    }

    return 0;
}

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

int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	int s = a + b + c;
	int m = max(max(a, b), c);
	if (m % 2 != s % 2) {
		m++;
	}
	cout << (m*3 - s) / 2 << endl;
	
}


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

using namespace std;
const int maxn=100005;
const int inf=0x3f3f3f3f;

int n,a[maxn],dp[maxn],k;

int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) dp[i]=(i==1?0:inf);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=2;i<=n;i++){
		for(int j=max(1,i-k);j<i;j++) dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
	}
	printf("%d\n",dp[n]);
}

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

using namespace std;

int main(){
        int a,b,c;
        cin >> a >> b;
        if(a>b){
                c=1;
                if(b==1){
                        c=2;
                }
        }else if(a<b){
                c=2;
                if(a==1){
                        c=1;
                }
        }else{
                c=0;
        }
        switch(c){
                case 0:
                        cout << "Draw" << endl;
                        break;
                case 1:
                        cout << "Alice" << endl;
                        break;
                case 2:
                        cout << "Bob" << endl;
                default:
                        break;
        }

        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("inputf.in", "r", stdin);
 //    freopen("outputf.in", "w", stdout);
 //    #endif
    ll n;
    ll m;
    cin>>n>>m;
    ll arr[n];
    ll sum=0;
    ll count=0;
    for(ll i=0;i<n;i++)
    {
    	cin>>arr[i];
    	sum=sum+arr[i];
    }
    float margin;
    ll i=0;
    margin=((float)sum/(4*m));
    while(count!=m && i<n)
	{
		if(arr[i]>=margin)
		{
			count++;
		}
		i++;
	}
	if(count==m)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}

}

Measured memory_bytes: 256
import std.stdio;
import std.format;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int popcnt(int x) {
    int Ret = 0;
    foreach (i; 0 .. 16) {
        if (x & (1 << i)) Ret++;
    }
    return Ret;
}

int popCount[1 << 16];
static this() {
    foreach (i; 0 .. (1 << 16)) {
        popCount[i] = popcnt(i);
    }
}

void main() {
    int N, C;
    int[] A, B;
    bool input() {
        scanf("%d %d\n", &N, &C);
        if (N == 0 && C == 0) return false;
        A = new int[N];
        B = new int[C];
        foreach (i; 0 .. N) {
            int bit;
            foreach (j, x; readln.chomp.split(" ").map!(to!int).array) {
                bit |= (x << j);
            }
            A[i] = bit;
        }
        foreach (i; 0 .. C) {
            int bit;
            foreach (j, x; readln.chomp.split(" ").map!(to!int).array) {
                bit |= (x << j);
            }
            B[i] = bit;
        }
        return true;
    }
    void solve() {
        static int dp[2][1<<16];
        memset(dp.ptr, -1, dp.sizeof);
        dp[0][0] = 0;
        foreach (i; 0 .. N) {
            dp[(i + 1) & 1][] = -1;
            foreach (j; 0 .. (1 << 16)) {
                if (dp[i & 1][j] == -1) continue;
                int bit = j | A[i];
                foreach (b; B) {
                    dp[(i + 1) & 1][bit & ~b] = max(dp[(i + 1) & 1][bit & ~b], dp[i & 1][j] + popCount[bit & b]);
                }
            }
        }
        writeln(dp[N & 1].reduce!max);
    }
    while (input) solve;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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


int main() {
	int n, m, c, start, goal;
	while (cin >> n >> m >> c >> start >> goal, n) {
		start--;
		goal--;
		vector<vector<vector<pll>>> E(c, vector<vector<pll>>(n));
		REP(i, m) {
			int x, y, d, co;
			cin >> x >> y >> d >> co;
			x--;
			y--;
			co--;
			E[co][x].push_back({ y,d });
			E[co][y].push_back({ x,d });
		}
		vector<int> num(c);
		REP(i, c) {
			cin >> num[i];
		}

		vvll cost(c, vll(n * 200,0));
		REP(i, c) {
			vi q(num[i] - 1);
			vi r(num[i]);
			REP(j, num[i] - 1)
				cin >> q[j];
			REP(j, num[i])
				cin >> r[j];
			int qidx = 0;
			int ridx = 0;
			FOR(j, 1, n * 200) {
				cost[i][j] = cost[i][j - 1] + r[ridx];
				if (!q.empty() && qidx < q.size() && j == q[qidx]) {
					qidx++;
					ridx++;
				}
			}
		}
		vvll E2(n, vll(n, 1e9));
		REP(i, c) {
			vvll E3(n, vll(n, 1e9));
			REP(j, n)
				E3[j][j] = 0;
			REP(j, n)
				if(!E[i][j].empty())
					REP(k, E[i][j].size())
						E3[j][E[i][j][k].first] =min(E3[j][E[i][j][k].first], E[i][j][k].second);
			REP(l, n)
				REP(j, n)
					REP(k, n)
					E3[j][k] = min(E3[j][k], E3[j][l]+E3[l][k]);
			REP(j, n)
				REP(k, n)
				if(E3[j][k]!=1e9)
					E2[j][k]=min(E2[j][k],cost[i][E3[j][k]]);
		}
		
		REP(i, n)
			REP(j, n)
				REP(k, n)
					E2[j][k] = min(E2[j][k], E2[j][i] + E2[i][k]);
		if (E2[start][goal] == 1e9)
			cout << -1 << endl;
		else
			cout << E2[start][goal] << endl;
	}

	return 0;
}

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n;
vint v;

signed main() {
    cin>>n;
    int x=6;
    v.pb(1);
    while(n>=x){
        v.pb(x);
        x*=6;
    }
    x=9;
    while(n>=x){
        v.pb(x);
        x*=9;
    }
    sort(all(v));
    //for(auto e:v)cout<<e<<endl;
    int dp[100001];
    rep(i,0,100001)dp[i]=100001;
    dp[0]=0;
    rep(i,0,n+1){
        rep(j,0,v.size()){
            if(i>=v[j])dp[i]=min(dp[i],dp[i-v[j]]+1);
        }
    }
    cout<<dp[n]<<endl;
    
    
    
    
    
    
    return 0;
}

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

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

    	while(true){
        	String strArr[] = br.readLine().split(" ");
            int a=Integer.parseInt(strArr[0]);
            String op=strArr[1];
            int b=Integer.parseInt(strArr[2]);

            if(op.equals("+")){
            	System.out.println(a+b);
            }

            else if(op.equals("-")){
            	System.out.println(a-b);
            }

            else if(op.equals("*")){
            	System.out.println(a*b);
            }

            else if(op.equals("/")){
            	System.out.println(a/b);
            }

            else if(op.equals("?")){
            	System.exit(0);
            }

            op="";
            a=0;
            b=0;
    	}
    }
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               2e9
#define INF_LL            1LL<<60
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


// 処理
void Solve()
{
	ll N;
	cin >> N;
	N++;
	VL A(N);
	REP(i, N) cin >> A[i];

	ll ans = -1;
	ll nowNum = 1;
	VL rootNum(N);
	REP(i, N) {
		nowNum -= A[i];
		if (nowNum < 0) {
			cout << -1 << endl;
			return;
		}
		rootNum[i] = nowNum;
		if (nowNum < 1e14) {
			nowNum *= 2;
		}
	}

	ll nowHa = 0;
	VL haSum(N);
	REVREP(i, N) {
		haSum[i] = nowHa;
		nowHa += A[i];
	}

	ans = accumulate(ALL(A), (ll)0);
	REP(i, N - 1) {
		ans += min(rootNum[i],  haSum[i]);
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 5556
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin >> X;
  int ans;
  for(int i=X;;i++){
    ans = i;
    for (int j=3;j<=i/2;j+=2){
      if (i%j==0) {
        ans = 0;
        break;
      }
    }
    if (ans!=0) break;
  }
  cout << ans;

}


Measured memory_bytes: 256
n = gets.to_s.to_i

memo = Array.new(n + 1){|i| Array.new(n + 1){|j| i.gcd(j) }}

ans = 0
1.upto(n) do |i|
  1.upto(n) do |j|
    t = memo[i][j]
    1.upto(n) do |k|
      ans += memo[t][k]
    end
  end
end
 
puts ans

Measured memory_bytes: 14344
// MandaA.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>
using namespace std;
int main()
{
	string S;
	cin >> S;
	string T;
	cin >> T;
	int L = S.size();
	for (int i = 0; i < L; i++)
	{
		if (S[i] != T[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}
	int L2 = T.size();
	if (L2 == L + 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int findRoots(int n,int x,int y){
	int a = 1;
	int b = x+y;
	int c = -n;
	int d = b*b-4*a*c;
	if(d < 0)
		return 0;
	
	if(((int)sqrt(d)) != sqrt(d))
		return 0;
	
	d = (int)sqrt(d);
	if(d <= b)
		return 0;
	
	if((d-b)%2 != 0)
		return 0;
	
	return 1;
}

int solve(int n){
	int total = 0;
	for(int x = 1; x*x <= n; x++){
		int rem = n-x*x;
		if(rem < 0)
			break;
		
		for(int y = 1; y*y <= rem; y++){
			int new_rem = rem-y*y-x*y;
			if(new_rem < 0)
				break;
			
			total += findRoots(new_rem,x,y);
		}
	}
	
	cout << total << '\n';
	return 0;
}

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		solve(i);
		
	return 0;
}

Measured memory_bytes: 3592
def main():
    N, K, S = list(map(int, input().split()))

    salt = -1 if S >= 10**9 else 1
    if K == 0:
        arr = [S+salt] *N
    else:
        arr = [] 
        for i in range(0, K):
            arr += [S]
        while len(arr) < N:
                arr += [S+salt]

    print(' '.join(map(str,arr)))

if __name__ == "__main__":
    main()


Measured memory_bytes: 15208
#include <cstdio>
#include <string>
using namespace std;

int main()
{
  int n, k;
  scanf("%d %d", &n, &k);
  char text[n];
  scanf("%s", text);
  text[k - 1] = text[k - 1] + 32;

  printf("%s\n", text);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n;
    cin >> n;
    ll a[n+1]; ll b[n+1]; ll c[n+1];
    rep1(i,n) cin >> a[i] >> b[i] >> c[i];
    int N = 1e5;
    ll dp[N+1][3];
    dp[0][0] = 0; dp[0][1] = 0; dp[0][2] = 0;
    dp[1][0] = a[1]; dp[1][1] = b[1]; dp[1][2] = c[1];
    for(int i = 2; i <= n; i++){
        dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
        dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
        dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
    }

    ll ans = max(dp[n][0], dp[n][1]);
    ans = max(ans, dp[n][2]);
    cout << ans << endl;
    return 0;
}

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

int f2(ll n){
  int cnt=0;
  while(n!=0){
    n/=2;
    cnt++;
  }
  return cnt;
}

int main(){
  int i,j,k,cnt;
  ll x,y;
  cin>>x>>y;
  cout<<f2(y/x);
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sati = 0
for i in range(N):
    if i != 0:
        if a[i] == a[i-1] + 1:
            sati += c[a[i-1]-1]
    sati += b[a[i]-1]

print(sati)

Measured memory_bytes: 38496
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

lint binpow(lint n, lint x, lint mod)
{
  lint tgt = 1;
  lint dig = n;
  while (x > 0) {
    if (x%2) {
      tgt = (tgt * dig) % mod;
    }
    dig = (dig * dig) % mod;
    x /= 2;
  }
  return tgt;
}

class Comb
{
private:
  lint mod;
  vector< lint > fact;
  vector< lint > factf;
public:
  Comb(lint size, lint mod) : mod(mod), fact(size+1, 0), factf(size+1, 0) {
    fact[0] = 1;
    factf[0] = 1;
    for (lint i = 1; i <= size; ++i) {
      fact[i] = fact[i-1]*i%mod;
      factf[i] = binpow(fact[i], mod-2, mod);
    }
  }
  lint comb(lint n, lint k) {
    if (n<k) return 0;
    if (k==0 || n==k) return 1;
    return ((fact[n] * factf[k]) % mod * factf[n-k]) % mod;
  }
};

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  lint mod = 1e9+7;
  Comb comb(3e6+1, mod);
  lint k;
  string s;
  cin >> k >> s;
  lint ans = 0;
  for (lint i=0; i<=k; ++i) {
    ans += comb.comb(i+s.size()-1, s.size()-1) * binpow(25, i, mod) % mod * binpow(26, k-i, mod) % mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 51128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

#define size_t int

using namespace std;
typedef long l;
typedef long long ll;

size_t mod(size_t a, size_t b) {
    return ((b + (a % b)) % b);
}

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

  float x;
  cin >> x;
  std::cout << pow(2,(int)log2(x)) << '\n';

  return 0;
}


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

bool isa(int m, int d) {
	int d1 = d / 10, d2 = d % 10;
	if (d1>=2&&d2>=2&&d1*d2 == m)return true;
	return false;
}

signed main() {
	int m, d; cin >> m >> d;
	int cnt = 0;
	rep(i, m) {
		rep(j, d) {
			if (isa(i + 1, j + 1))cnt++;
		}
	}
	cout << cnt << endl;
}

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

int main()
{
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i = 0; i < N; i++)
  {
    cin >> d.at(i);
    
    for(int j = 0; j < i; j++)
    {
      if(d.at(i) <= d.at(j))
        continue;
      
      // shift the values to the latter of arrangement
      int prev = d.at(i);
      for(int k = j; k <= i; k++)
      {
        int current = prev;
        prev = d.at(k);
        d.at(k) = current;
      }
    }
  }
  
  int count = 1;
  for (int i = 0; i < N - 1; i++)
  {
    if(d.at(i) > d.at(i + 1))
      count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  vector<string> word(1);
  for(int i = 0; i < N; i++) {
    cin >> s.at(i);
    if(i == 0) word.at(0) = s.at(0);
    else {
      for(int j = 0; j < word.size(); j++) {
        if(s.at(i) == word.at(j)) break;
      }
    word.push_back(s.at(i));
    }
  }
  
  int M;
  cin >> M;
  vector<string> t(M);
  for(int i = 0; i < M; i++) cin >> t.at(i);
  
  vector<int> point(word.size(), 0);
  
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < word.size(); j++) {
      if(word.at(j) == s.at(i)) point.at(j)++;
    }
  }
  
  for(int i = 0; i < M; i++) {
    for(int j = 0; j < word.size(); j++) {
      if(word.at(j) == t.at(i)) point.at(j)--;
    }
  }
  
  int max = 0;
  
  for(int i = 0; i < point.size(); i++) {
    if(point.at(i) > max) max = point.at(i);
  }
  
  cout << max << endl;
}

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


int main() {
  
  int n;
  cin>> n;
  
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
    
    int c=0;
    for(int i=1;i<n;i++){
      if(vec.at(i)==vec.at(i-1)){
        c++;
      }
    }
  
  if(c>0){
    cout<<"NO" <<endl;
  }
  else{
    cout << "YES" <<endl;
  }
}
  



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <cstring>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

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

    string r, a;
    while(cin >> r >> a)
    {
        if(r == "0") break;

        int ans = 0;
        set<int> x, y;

        REP(i, 4)
        {
            if(r[i] == a[i])
            {
                ans++;
            }

            x.insert(r[i]);
            y.insert(a[i]);
        }

        int cnt = 0;

        for(auto i : x)
        {
            if(y.count(i))
            {
                cnt++;
            }
        }

        cout << ans << " " << cnt - ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3132
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve

solve :: [Int] -> Int
solve [r, g, b, n] = length [(x, y) | x <- [0..(n `div` r)], y <- [0..(n `div` g)], n - r * x - g * y >= 0, (n - r * x - g * y) `mod` b == 0]

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 764
// Copyright (c) 2018
// All Rights Reserved.

#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char *argv[])
{
  int n, m, x, y;
  std::cin >> n >> m >> x >> y;
  std::vector<int> xvec;
  std::vector<int> yvec;
  for (auto i = 0; i < n; i++) {
    int xelem;
    std::cin >> xelem;
    xvec.emplace_back(xelem);
  }

  for (auto i = 0; i < m; i++) {
    int yelem;
    std::cin >> yelem;
    yvec.emplace_back(yelem);
  }

  std::sort(xvec.begin(), xvec.end(), [](int a, int b) {
      return a > b;
    });
  std::sort(yvec.begin(), yvec.end());

  std::string result = (yvec[0] > xvec[0] && yvec[0] <= y && yvec[0] > x) ?
                       "No War" : "War";
  std::cout << result;
  return 0;
}


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

int main(){
    int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time1 = h1*60+m1;
    int time2 = h2*60+m2;
    int ans = time2 - time1 - k;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;


int main() {
    int n; cin >> n;
    ll c; cin >> c;
    vector<ll> x(n), v(n);
    int mni=n;
    rep(i,n) {
        cin >> x.at(i) >> v.at(i);
    }

    ll mx = 0, mx2 = 0;
    ll sum = 0;
    int id = n-1;
    int id2 = n-1;
    vector<ll> fa(n), fa2(n);
    for(int i=0; i<n; i++){
        sum += v.at(i);
        mx = max(mx, sum - x.at(i)); 
        mx2 = max(mx2, sum - 2*x.at(i)); 
        fa.at(i) = mx;
        fa2.at(i) = mx2;
    }

    ll ans = max(fa.at(n-1), fa2.at(n-1)); 
    sum = 0;
    mx = 0; mx2 = 0;
    for(int i=n-1; i>=0; i--){
        sum += v.at(i);
        mx = max(mx, sum-2*(c-x.at(i)));
        mx2 = max(mx2, sum-(c-x.at(i)));
        if(i!=0)ans = max(ans, mx+fa.at(i-1));
        if(i!=0)ans = max(ans, mx2+fa2.at(i-1)); 
        else ans = max(ans, max(mx, mx2));
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>

int main(){
//	ios_base::sync_with_stdio(false);
 //   cin.tie(NULL);
    
    int n;
    cin>>n;
   // cout<<"hi\n";
    ll a[n+1];
    for(int i=1;i<=n;i++){
    	cin>>a[i];
	}
	//cout<<"hi\n";
	ll dp[n+1];
	for(int i=1;i<=n;i++)
	dp[i]=0;
	dp[1]=1000;
	for(int i=1;i<=n;i++){
		ll num=dp[i]/a[i];
		ll div=dp[i]%a[i];
		for(int j=i+1;j<=n;j++){
			dp[j]=max(dp[j],dp[i]);
			dp[j]=max(dp[j],num*a[j]+div);
		}
	}
	cout<<dp[n];	
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <deque>
#include <numeric>
#include <set>
using namespace std;

const int INF = 1e+9;

int n;
vector<int> graph[205];
int color[205];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

int dist[205][205];
void warshall_floyd(){
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

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

    cin >> n;
    fill((int*)dist, (int*)(dist + n), INF);
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < n; ++j){
            if(i < j && s[j] == '1'){
                graph[i].push_back(j);
                graph[j].push_back(i);
                dist[i][j] = 1;
                dist[j][i] = 1;
            }
        }
    }
    for(int i = 0; i < n; ++i){
        dist[i][i] = 0;
    }

    if(!bipartite_jugding(0, 1)){
        cout << -1 << endl;
        return 0;
    }

    int res = 0;
    warshall_floyd();
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(dist[i][j] != INF){
                res = max(res, dist[i][j]);
            }
        }
    }

    cout << res + 1 << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    string s,t;
    cin >>s >>t;

    int S=s.size(), T=t.size();

    int ans=0;
    for(int L=min(S,T); L>=1; --L)
    {
        set<vector<int>> h;

        vector<int> ct(26,0);
        rep(i,L) ++ct[t[i]-'a'];

        h.insert(ct);
        for(int i=1; i<=T-L; ++i)
        {
            --ct[t[i-1]-'a'];
            ++ct[t[i-1+L]-'a'];
            h.insert(ct);
        }

        bool found=false;

        ct=vector<int>(26,0);
        rep(i,L) ++ct[s[i]-'a'];

        if(h.find(ct) != h.end())
        {
            ans=L;
            break;
        }

        for(int i=1; i<=S-L; ++i)
        {
            --ct[s[i-1]-'a'];
            ++ct[s[i-1+L]-'a'];
            if(h.find(ct) != h.end())
            {
                found=true;
                ans=L;
                break;
            }
        }

        if(found) break;
    }

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

Measured memory_bytes: 4000
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int ctoi(char);

int main()
{
    int H, W;
    cin >> H >> W;

    vector<string> array;

    rep(i, H)
    {
        string S;
        cin >> S;
        array.push_back(S);
    }

    rep(i, H)
    {
        rep(j ,W)
        {
            if (array[i][j] != '#')
            {
                int num = 0;
                if (i!=0)
                {
                    if (array[i-1][j] == '#')
                    {
                        num++;
                    }
                }
                if (i!=0 && j!=0)
                {
                    if (array[i-1][j-1] == '#')
                    {
                        num ++;
                    }
                }
                if (j!=0)
                {
                    if (array[i][j-1] == '#')
                    {
                        num++;
                    }
                }
                if (i!=H-1 && j!=0)
                {
                    if (array[i+1][j-1] == '#')
                    {
                        num ++;
                    }
                }
                if (i != H-1)
                {
                    if (array[i+1][j] == '#')
                    {
                        num ++;
                    }
                }
                if (i != H-1 && j != W-1)
                {
                    if (array[i+1][j+1] == '#')
                    {
                        num ++;
                    }
                }
                if (j != W-1)
                {
                    if (array[i][j+1] == '#')
                    {
                        num++;
                    }
                }
                if (i != 0 && j != W-1)
                {
                    if (array[i-1][j+1] == '#')
                    {
                        num ++;
                    }
                }
                char tmp[1];
                sprintf(tmp, "%d", num); 
                array[i][j] = tmp[0];
            }
        }
    }
    

    rep(i, H)
    {
        rep(j, W)
        {
            cout << array[i][j];
        }
        cout << endl;
    }
}


int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c -'0';
    }
    return -1;
}


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

int check(char s[]) {
    int n = strlen(s);
    if (n % 2 == 1) return 0;
    for (int i=0; s[i]; i++) {
        if (i % 2 == 0 && s[i] != 'h') {
            return 0;
        } else if (i % 2 == 1 && s[i] != 'i') {
            return 0;
        }
    }
    return 1;
}

int main() {
    char s[15]; scanf("%s", s);
    puts(check(s) ? "Yes" : "No");
    return 0;
}


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

int main()
{
	string S;

	cin >> S;
	int n = S.size();
	string ans = "Yes";
	for (int i = 0; i < n / 2; i++)
	{
		if (S[i] != S[n - 1 - i]) {
			ans = "No";
		}
	}
	for (int i = 0; i < n / 2; i++)
	{
		if (S[i] != S[n / 2 - 1 - i])
		{
			ans = "No";
		}
	}
	for (int i = (n+1)/2; i < n; i++)
	{
		if (S[i] != S[n-1-(i-(n+1)/2)])
		{
			ans = "No";
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
	int i,h,k;
	int height[5]={0,0,0,0};
	for(i=0;i<10;i++){
		scanf("%d", &h);
		for(k=0;k<3;k++){
			if(height[k]<=h){
				height[k+2]=height[k+1];
				height[k+1]=height[k];
				height[k]=h;
				break;
			}
		}
	}
	printf("%d\n%d\n%d\n",height[0],height[1],height[2]);
	return 0;
}

Measured memory_bytes: 0
# coding:utf-8
import itertools
import math


def distance(t1, t2):
    return(math.hypot(t1[0] - t2[0], t1[1] - t2[1]))


def main():

    n = int(input())
    town = (tuple(map(int, input().split())) for _ in range(n))
    ans = 0

    for item in itertools.permutations(town, r=2):
        # print(*item)
        ans += distance(*item)

    print(ans / n)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace Atcoder
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var input = ReadTexts();

            int k = input[0].ToInt();

            input = ReadTexts();
            int a = input[0].ToInt();
            int b = input[1].ToInt();

            for (int i = a; i <= b; i++)
            {
                if (i % k == 0)
                {
                    return "OK";
                }
            }

            return "NG";
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }

        #endregion
    }

    public static class CastExtention
    {
        public static long ToLong(this string a) { return long.Parse(a); }
        public static int ToInt(this string a) { return int.Parse(a); }
    }
}



Measured memory_bytes: 28324
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>


int main() {
	std::string s, t; std::cin >> s >> t;
	std::vector<std::vector<int>> next(s.size());
	std::vector<int> next_position(26, -1);
	for (auto i = 0; i < s.size(); ++i) {
		if (next_position[s[i] - 'a'] == -1) next_position[s[i] - 'a'] = i;
	}
	for (int i = s.size() - 1; i >= 0; --i) {
		next[i] = next_position;
		next_position[s[i] - 'a'] = i;
	}
	long long int count = 0;
	int position = next_position[t.front() - 'a'];
	for (auto i = 1; i < t.size() && position != -1; ++i) {
		auto c = t[i];
		if (next[position][c - 'a'] <= position) {
			++count;
		}
		position = next[position][c - 'a'];
	}
	if (position != -1) std::cout << count * s.size() + position + 1 << std::endl;
	else std::cout << -1 << std::endl;
}


Measured memory_bytes: 13696
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
      int a,i,b,j = 0;
      char r[256];
      scanf("%s",r);

      for(i=0;i<4;i++) {

            if(r[i] == '2')  j++;

      }

      printf("%d\n",j);

      return 0;
}

Measured memory_bytes: 128
def main():
	while True:
		w,h=map(int,input().split())
		if w==0 and h==0:
			break
		ok=[[True for j in range(w)] for i in range(h)]
		n=int(input())
		for i in range(n):
			x,y=map(int,input().split())
			ok[y-1][x-1]=False
		dp=[[0 for j in range(w)] for i in range(h)]
		dp[0][0]=1
		for i in range(h):
			for j in range(w):
				if i+1<h and ok[i+1][j]:
					dp[i+1][j]+=dp[i][j]
				if j+1<w and ok[i][j+1]:
					dp[i][j+1]+=dp[i][j]
		print(dp[h-1][w-1])

if __name__=="__main__":
	main()



Measured memory_bytes: 5608