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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	double n;
	scanf("%lf", &n);

	double tmp = n/1.1;
	bool flag = false;
	
	for(double i = (int)tmp; ;i++)
	{
		// printf("%d\n", (int)(i*(1.08)));

		if(int(i*1.08) == n)
		{
			printf("%d\n", int(i));
			flag = true;
			break;
		}

		if(i*1.08 > n)
		{
			break;
		}
	}

	if(!flag)
		printf(":(\n");

	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int X[1010],Y[1010],H[1010];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>X[i]>>Y[i]>>H[i];
	
	for(x=0;x<=100;x++) {
		for(y=0;y<=100;y++) {
			
			ll R;
			FOR(i,N) if(H[i]>0) {
				R=H[i]+abs(x-X[i])+abs(y-Y[i]);
				break;
			}
			
			FOR(i,N) if(H[i]!=max(0LL,R-abs(x-X[i])-abs(y-Y[i]))) break;
			if(i==N) {
				cout<<x<<" "<<y<<" "<<R<<endl;
				return;
			}
			
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
while True:
    H, W = [int(i) for i in input().split()]
    if W == 0 and H == 0:
        break
    for i in range(0, H):
        if i == 0:
            print('#' * W)
        elif i == (H - 1):
            print('#' * W)
        elif H == 1:
            break
        else:
            print('#', '.' * (W - 2), '#', sep='')
    print()

Measured memory_bytes: 7684
'use strict'

function main(s) {
  	let orders = s.split(' ').map(n => Number(n));
  	let N = orders[0],K = orders[1];
  	let ans = K *  Math.pow(K - 1, N - 1);
    console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,int>;

template<typename T> T inf;
template<> constexpr int inf<int> = 1<<30;
template<> constexpr ll inf<ll> = 1LL<<60;
template<> constexpr double inf<double> = 1e30;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 1003;

using Cost = double;
using Node = int;
struct Edge{
  Cost cost; Node to;
  Edge(Cost cost,Node to)
    :cost(cost),to(to){}
};
using Graph = vector<vector<Edge>>;

vector<Cost> dijkstra
(Graph &graph, Node start, Cost zero = 0LL)
{
  using Pcn = pair<Cost,Node>;
  priority_queue<Pcn,vector<Pcn>,greater<Pcn>> que;
  vector<Cost> dist(graph.size(),inf<Cost>);
  dist[start] = zero;
  que.push(Pcn(zero,start));
  while(!que.empty()){
    Pcn p = que.top(); que.pop();
    Node v = p.second; //行き先
    if(dist[v] < p.first)  continue;
    for(Edge e : graph[v]){
      if(dist[v]+e.cost < dist[e.to]){
        dist[e.to] = dist[v]+e.cost;
        que.push(Pcn(dist[e.to],e.to));
      }
    }
  }
  return dist;
}

Graph graph;

double x[MAX_N],y[MAX_N],r[MAX_N];

int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int N; cin >> N;
  x[0] = x1; y[0] = y1; r[0] = 0;
  x[N+1] = x2; y[N+1] = y2; r[N+1] = 0;
  rep(i,N){
    scanf("%lf%lf%lf",x+i+1,y+i+1,r+i+1);
  }
  graph.resize(N+2);
  rep(i,N+1) REP(j,i+1,N+2){
    double c = max(0.0,hypot(x[i]-x[j],y[i]-y[j])-(r[i]+r[j]));
    graph[i].pb(Edge(c,j));
    graph[j].pb(Edge(c,i));
  }
  vector<Cost> dist;
  dist = move(dijkstra(graph,0));
  printf("%.10lf\n",dist[N+1]);
  return 0;
}

Measured memory_bytes: 22532
//This code was made by Chinese_zjc_
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
inline int rd(int &ddd)
{
	char tmp=getchar();
	int xxx=1;
	ddd=0;
	while(('0'>tmp||tmp>'9')&&tmp!='-'&&tmp!=EOF)
	{
		tmp=getchar();
	}
	if(tmp==EOF)
	{
		return EOF;
	}
	if(tmp=='-')
	{
		xxx=-1;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		ddd=(ddd<<3)+(ddd<<1)+(tmp^48);
		tmp=getchar();
	}
	return ddd*=xxx;
}
inline char rd(char &ddd)
{
	char tmp=getchar();
	while(tmp==' '||tmp=='\n')
	{
		tmp=getchar();
	}
	if(tmp==EOF)
	{
		return EOF;
	}
	return ddd=tmp;
}
inline int max(const int &A,const int &B)
{
	return A<B?B:A;
}
inline int min(const int &A,const int &B)
{
	return A<B?A:B;
}
int n,ans,sum;
string s[100001];
signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
	{
		cin>>s[i];
		for(int j=9;j>0;--j)
		{
			for(int k=0;k<j;++k)
			{
				if(s[i][k]<s[i][k+1])
				{
					swap(s[i][k],s[i][k+1]);
				}
			}
		}
	}
	sort(s+1,s+1+n);
	for(int i=2;i<=n;++i)
	{
		if(s[i]==s[i-1])
		{
			++sum;
			ans+=sum;
		}
		else
		{
			sum=0;
		}
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 100000000
using namespace std;
int main(){
  int n,m[150];
  int a[150][150];
  while(1){
    cin >> n;
    if(n==0) break;
    rep(i,n){
      cin >> m[i];
      rep(j,m[i]){
	cin >> a[i][j];
      }
    }/*
    rep(i,n){
      rep(j,m[i]){
	cout << a[i][j] << " ";
      }
      cout << endl;
      }*/
    int K,tmp;
    cin >> K;
    int l[150];
    vector<int> ans;
    int count[150]={};
    rep(i,K) cin >> l[i];
    rep(i,n){
      rep(j,m[i]){
	rep(k,K){
	  //cout << l[k] << " " << a[i][j] << endl; 
	  if(l[k] == a[i][j]){
	    count[i]++;
	  }
	  //cout << count << endl;
	}
	//if(count == m[i]) ans.push_back(i+1);
      }
    }
    rep(i,n) if(count[i]==K) ans.push_back(i+1);
    //rep(i,ans.size()) cout << ans[i] << " ";
    //cout << ans.size() << endl;
    if(ans.size()==1) cout << ans.front() << endl;
    else cout << -1 << endl;
    ans.clear();
  }
  
  return 0;
}



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

using P = pair<int, int>;

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    ll ans = 0;
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#' && !visited[i][j]) {
                ll black = 0;
                ll white = 0;
                queue<P> q;
                q.push(P{i, j});
                visited[i][j] = true;
                black++;
                while (!q.empty()) {
                    P p = q.front();
                    q.pop();

                    rep(i, 4) {
                        P np = P{p.first + dy[i], p.second + dx[i]};
                        if (np.first < 0 || H <= np.first || np.second < 0 || W <= np.second) continue;
                        if (visited[np.first][np.second]) continue;
                        if (S[p.first][p.second] == S[np.first][np.second]) continue;

                        q.push(np);
                        visited[np.first][np.second] = true;
                        if (S[np.first][np.second] == '#') black++;
                        else white++;
                    }
                }

                ans += black * white;
            }
        }
    }

    cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B; cin >> A >> B;
    priority_queue<ll> q; q.push(A); q.push(B);
    ll ans = 0;
    rep(i, 2){
        ll v = q.top();
        ans += v;
        q.pop();
        q.push(v - 1);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<vector<ll>> d(301,vector<ll>(301,1e18)); 
void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main(){
    ll N;
    cin >> N;
    vector<vector<ll>> A(N,vector<ll>(N));
    rep(i,N){
        rep(j,N){
            cin >> A[i][j];
            d[i][j] = A[i][j];
        }
    }
    warshall_floyd(N);
    rep(i,N){
        rep(j,N){
            if(d[i][j] != A[i][j]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    ll ans = 0;
    rep(i,N){
        REP(j,i+1,N){
            ans += d[i][j];
        }
    }
    rep(i,N){
        REP(j,i+1,N){
            rep(k,N){
                if(i == j) continue;
                if(j == k) continue;
                if(k == i) continue;
                if(d[i][j] == d[i][k] + d[k][j]){
                    ans -= d[i][j];
                    break;
                } 
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5044
n, m, l = map(int, input().split())
mat_A = [list(map(int, input().split())) for _ in range(n)]
mat_B = [list(map(int, input().split())) for _ in range(m)]


for row in mat_A:
    result_row = []
    for col in zip(*tuple(mat_B)):
        c = 0
        for pair in zip(row, col):
            c += pair[0] * pair[1]
        result_row.append(c)
    print(" ".join(map(str, result_row)))


Measured memory_bytes: 6248
N = int(input())
A = list(map(int, input().split()))



A_sum = 0
for i in range(0, N, 1):
    A_sum = A_sum + A[i]

A_sum_sq = A_sum * A_sum

idv_sq_sum = 0
for i in range(0, N, 1):
    idv_sq_sum += A[i] * A[i]

Answer = (A_sum_sq -
          idv_sq_sum) // 2
print(Answer%(10**9 + 7))

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int mat[101][101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	if(N%2==0) {
		for(x=1;x<=N;x++) {
			for(y=1;y<=N;y++) {
				if(x+y!=N+1) mat[x][y]=1;
			}
		}
	}
	else if(N*(N+1)/2%2==0) {
		set<int> A;
		int tot=N*(N+1)/2/2;
		for(i=N;i>=1;i--) {
			if(tot>=i) {
				A.insert(i);
				tot-=i;
			}
		}
		for(x=1;x<=N;x++) {
			for(y=1;y<=N;y++) {
				if(A.count(x)+A.count(y)==1) mat[x][y]=1;
			}
		}
	}
	else {
		for(x=1;x<=N-1;x++) {
			for(y=1;y<=N-1;y++) {
				if(x+y!=N) mat[x][y]=1;
			}
		}
		for(x=1;x<=N-1;x++) mat[x][N]=mat[N][x]=1;
	}
	
	vector<pair<int,int>> V;
	int sum[101]={};
	for(x=1;x<=N;x++) {
		for(y=x+1;y<=N;y++) {
			if(mat[x][y]) {
				V.push_back({x,y});
				sum[x]+=y;
				sum[y]+=x;
			}
		}
	}
	for(x=1;x<=N;x++) assert(sum[1]==sum[x]);
	
	cout<<V.size()<<endl;
	FORR(v,V) cout<<v.first<<" "<<v.second<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

string s;

int main(void) {
  // Here your code !
  cin >> s;

  int last;
  if (s[0] == s.back()) {
    last = (s.size() - 3) % 2;
  }
  else {
    last = (s.size() - 2) % 2;
  }

  if (last == 0) {
    printf("Second\n");
  }
  else {
    printf("First\n");
  }

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int k, s; cin >> k >> s;
	int ans = 0;
	rep(i, k + 1){
		rep(j, k + 1){
			int z = s - i - j;
			if(0 <= z && z <= k) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int H,W,N;
  cin >> H >> W >> N;
  int r,c;
  cin >> r >> c;
  r--;
  c--;
  string S,T;
  cin >> S >> T;
  int DP[(2*N)+1][4];
  // L : 0,R : 1,U : 2,D : 3
  DP[0][0] = c;
  DP[0][1] = c;
  DP[0][2] = r;
  DP[0][3] = r;
  bool can = true;
  for (int i = 0; i < (2*N); i++) {
    DP[i+1][0] = DP[i][0];
    DP[i+1][1] = DP[i][1];
    DP[i+1][2] = DP[i][2];
    DP[i+1][3] = DP[i][3];
    if (i % 2 == 0) {
      if (S[i/2] == 'L') {
        DP[i+1][0]--;
      } else if (S[i/2] == 'R') {
        DP[i+1][1]++;
      } else if (S[i/2] == 'U') {
        DP[i+1][2]--;
      } else {
        DP[i+1][3]++;
      }
    } else {
      if (T[i/2] == 'L') {
        DP[i+1][1]--;
        DP[i+1][1] = max(0,DP[i+1][1]);
      } else if (T[i/2] == 'R') {
        DP[i+1][0]++;
        DP[i+1][0] = min(W-1,DP[i+1][0]);
      } else if (T[i/2] == 'U') {
        DP[i+1][3]--;
        DP[i+1][3] = max(0,DP[i+1][3]);
      } else {
        DP[i+1][2]++;
        DP[i+1][2] = min(H-1,DP[i+1][2]);
      }
    }

    for (int j = 0; j < 2; j++) {
      if (0 <= DP[i+1][j] && DP[i+1][j] < W) {
        
      } else {
        can = false;
      }
    }
    for (int j = 2; j < 4; j++) {
      if (0 <= DP[i+1][j] && DP[i+1][j] < H) {
        
      } else {
        can = false;
      }
    }
  }

  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

void dfs(int root, vector<vector<int> > graph, int n, vector<int>& dis) {
	stack<int>order;
	vector<bool>seen(n, false);
	order.push(root);
	while (!order.empty()) {
		int now = order.top();
		order.pop();
		seen[now] = true;
		for (int i = 0; i < graph[now].size(); i++) {
			if (!seen[graph[now][i]]) {
				order.push(graph[now][i]);
				dis[graph[now][i]] = dis[now] + 1;
			}
		}
	}
}

void solve() {
	int n, u, v, ans = 0; cin >> n >> u >> v; u--; v--;
	int t;
	vector<vector<int> >graph(n);
	vector<int>t_dis(n), a_dis(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		graph[a].emplace_back(b);
		graph[b].emplace_back(a);
	}
	dfs(u, graph, n, t_dis);
	dfs(v, graph, n, a_dis);
	for (int i = 0; i < n; i++) {
		if (a_dis[i] - t_dis[i] > 0) {
			if (ans < a_dis[i]) {
				ans = a_dis[i];
			}
		}
	}
	cout << ans - 1 << endl;
}

int main() {
	solve();
}

Measured memory_bytes: 12160
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int H1 = Integer.parseInt(sc.next());
    int M1 = Integer.parseInt(sc.next());
    int H2 = Integer.parseInt(sc.next());
    int M2 = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    if(H1 >= 0 && H1 <= 23 && H2 >= 0 && H2 <= 23 &&
       M1 >= 0 && M1 <= 59 && M2 >= 0 && M2 <= 59 && K >= 1){
      
      int ans = M2 + (H2 - H1)*60 - M1 -K;
      System.out.println(ans);
      
    }else{
      System.out.println("入力条件に違反しています");
    }
    
    
  }
  
}

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

int main()
{
  int A, B;
  cin >> A >> B;

  int ans = false;

  for (int i = 0; i < 3; i++)
  {
    if (A * B * i % 2 == 1)
      ans = true;
  }

  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3628
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
	vector<string> str;
	vector<string> ans;
	string s[120];
	int n;
	
	cin >> n;
	
	for (int i = 0; i < n; i++){
		cin >> s[i];
	}
	
	for (int k = 0; k < n; k++){
		str.clear();
		ans.clear();
		for (unsigned int i = 0; i < s[k].size(); i++){
			string str1(s[k].substr(0, i));
			string str2(s[k].substr(i, s[k].size() - i));
			str.push_back(str1 + str2);
			str.push_back(str2 + str1);
			
			reverse(str1.begin(), str1.end());
			str.push_back(str1 + str2);
			str.push_back(str2 + str1);
			
			reverse(str1.begin(), str1.end());
			reverse(str2.begin(), str2.end());
			str.push_back(str1 + str2);
			str.push_back(str2 + str1);
			
			reverse(str1.begin(), str1.end());
			str.push_back(str1 + str2);
			str.push_back(str2 + str1);
		}
		
		unsigned int n = 1;
		ans.push_back(s[k]);
		for (unsigned int i = 0; i < str.size(); i++){
			bool f = true;
			for (unsigned int j = 0; j < ans.size(); j++){
				if (str[i] == ans[j]){
					f = false;
					break;
				}
			}
			if (f){
				n++;
				ans.push_back(str[i]);
			}
		}
		
		cout << n << endl;
	}
	
	return (0);
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, r, g, b;
string s;
int ans = 1;
const int m = 998244353;
signed main() {
	cin >> n >> s;
	rep(i, 3 * n) {
		if (s[i] == 'R' && g && b) {
			ans *= min(g, b) % m;
			ans %= m; g--; b--;
		}
		else if (s[i] == 'R') {
			if (max(g, b) > r)ans *= max(g, b) - r;
			r++;
		}
		if (s[i] == 'G' && r && b) {
			ans *= min(r, b) % m; ans %= m;
			r--; b--;
		}
		else if (s[i] == 'G') {
			if (max(r, b) > g)ans *= max(r, b) - g;
			g++;
		}
		if (s[i] == 'B' && r && g) {
			ans *= min(r, g) % m; ans %= m;
			r--; g--;
		}
		else if (s[i] == 'B') {
			if (max(r, g) > b)ans *= max(r, g) - b;
			b++;
		}
		ans %= m;
	}
	REP(i, n + 1) {
		ans *= i; ans %= m;
	}
	cout << ans << endl;
}

Measured memory_bytes: 900
def main():
    s = list(map(int,input().strip().split()))
    k = s[3]
    r = 0
    if s[0] <= k:
        r += 1 * s[0]
        k -= s[0]
    else:
        r += 1 * k
        print(r)
        return
    
    if (k-s[1]) <=0:
        print(r)
        return
    
    if s[2] <= (k-s[1]):
        r += (-1)*s[2]
    else:
        r += (-1) * (k-s[1])
    
    print(r)
    return
    
    
main()


Measured memory_bytes: 9112
// atcoder/abc049/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  char c;
  while (cin >> c) {
    if (string("aiueo").find(c) != string::npos) cout << "vowel" << endl;
    else cout << "consonant" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    r, D, x_2000 = map(int, input().split())

    x_prev = x_2000
    for i in range(10):
        x = r * x_prev - D
        print(x)
        x_prev = x


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	vector<int> num(3);
	for (int i = 0; i < 3; i++) cin >> num[i];
	sort(num.begin(), num.end(), greater<int>());
	int ans = num[0] * 10 + num[1] + num[2];
	cout << ans << endl;
	return 0;
}

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

int main()
{
    char s;
    cin >> s;
    if (isupper(s))
        cout << 'A' << endl;
    else
        cout << 'a' << endl;
    return 0;
}

Measured memory_bytes: 3628
Main = input => {
  input = input.split("\n");
  const n = Number(input[0]);
  const a = input[1].split(" ").map(x => Number(x));
  
  const ans = new Array(n);
  a.forEach((x, id) => {
    ans[x-1] = id+1;
  });
  
  const result = [];
  ans.forEach(x => result.push(x));
  
  console.log(result.join(" "));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34400
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

	    String[] line = br.readLine().split(" ");
	    double x1 = Double.parseDouble(line[0]);
	    double y1 = Double.parseDouble(line[1]);
	    double x2 = Double.parseDouble(line[2]);
	    double y2 = Double.parseDouble(line[3]);

	    double x = Math.pow(Math.abs(x1 - x2), 2);
	    double y = Math.pow(Math.abs(y1 - y2), 2);

	    double ans = Math.sqrt(x + y);

	    System.out.println(ans);
	}
}

Measured memory_bytes: 24492
data=int(input())
count=0
 
for i in range(10):
  c=data%(i+1)
  if c==0:
    a=i+1
    b=data//(i+1)
    if a<=9 and b<=9 :
      count+=1
      
if count>=1:
  print("Yes")
if count==0:
  print("No")

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();

            out.println(700 + 100 * s.chars().filter(x -> x == 'o').count());
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 26324
import itertools
import functools
import math
from collections import Counter
from itertools import combinations

def combinations_count(n, r):
    return math.factorial(int(n)) // (math.factorial(int(n - r)) * math.factorial((r)))

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

C=Counter(A)

C1=[0]*(N+1)
C2=[0]*(N+1)

sum = 0
for i in range(0,2*10**5):
    if C[i] > 1:
        n = C[i]
        r = 2
        sum += combinations_count(n,r)

for i in range(1,N+1):
    s=A[i-1]
    n=C[s]-1
    print(sum-n)

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		
		if(N*A >= B) {
			System.out.println(B);
		}
		else {
			System.out.println(N*A);
		}

	}

}

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

using namespace std;

typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define pi 3.141592653589
#define inf 4e18
#define MOD 998244353
#define pb push_back
#define endl "\n"
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

lli T[800004];
lli S[800004];
lli E[800004];
lli a[200004];

void build(int node,int low,int high){
	S[node]=low;
	E[node]=high;
	if (low==high){
		T[node]=a[low]%MOD;
		return;
	}
	else{
		int mid=low+(high-low)/2;
		build(2*node,low,mid);
		build(2*node+1,mid+1,high);
		T[node]=(T[2*node]%MOD+T[2*node+1]%MOD)%MOD;
	}
	return;
}

void update(int node,int index,int value){
	if (S[node]==E[node]){
		T[node]=value%MOD;
		a[index]=value%MOD;
		return;
	}
	else{
		if (index<=(S[node]+E[node])/2) update(2*node,index,value);
		else update(2*node+1,index,value);
		T[node]=(T[2*node]%MOD+T[2*node+1]%MOD)%MOD;
	}
	return;
}

lli query(int node,int l,int r){
	if (S[node]>r || E[node]<l) return 0;
	else if (S[node]>=l && E[node]<=r) return T[node];
	else{
		lli left=query(2*node,l,r);
		lli right=query(2*node+1,l,r);
		return (left+right)%MOD;
	}
	return 0;
}

int main(){
	fast;
	lli n,k,x,y;
	cin>>n>>k;
	vector <pii> uni(k);
	for (int i=0;i<k;i++){
		cin>>uni[i].ff>>uni[i].ss;
	}
	sort(all(uni));
	a[n]=1;
	build(1,1,n);
	for (int i=n-1;i>=1;i--){
		int val=0;
		for (int j=0;j<k;j++){
			if (i+uni[j].ff<=n){
				val=(val%MOD+query(1,i+uni[j].ff,min(i+uni[j].ss,n)))%MOD;
			}
			else break;
		}
		update(1,i,val);
	}
	cout<<a[1]<<endl;
}

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

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  int count = 0;
  for (int i = 0; i < n - 2; ++i) {
    if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C')
      ++count;
  }
  std::cout << count << std::endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string In = Console.ReadLine();
            char C = In[0];
            string A = "abcdefghijklmnopqrstuvwxyz";
            for(int i=0; i<25; i++){
                if (A[i] == C)
                {
                    Console.WriteLine(A[i + 1]);
                }
            }
        }

    }
}

Measured memory_bytes: 11092
n, m = (int(i) for i in input().split())
ok = [1] * n
l, r = (1,n)
for i in range(1,m+1):
  tmp_l, tmp_r = (int(j) for j in input().split())
  if l < tmp_l:
    l = tmp_l
  if r > tmp_r:
    r = tmp_r

print( r-l+1 if r-l+1>0 else 0 )

Measured memory_bytes: 3956
#include <cstdio>

char st[199999];
int dist[99];
int K;
int main() {
	scanf("%s",st);
	scanf("%d",&K);
	int N=0;
	while(st[N]!='\0') N++;
	dist[0]=0;
	for(int i=1;i<26;i++) dist[i]=26-i;
	for(int i=0;i<N-1;i++) {
		int vl=(int)(st[i]-'a');
		if(dist[vl]<=K) {
			K-=dist[vl];
			printf("a");
		} else {
			printf("%c",st[i]);
		}
	}
	int lst=(int)(st[N-1]-'a');
	lst=(lst+K)%26;
	printf("%c\n",'a'+(char)lst);
	return 0;
}


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

using namespace std;

bool check(string s)
{
    if (s[0] != 'A') {return false;}

    int c = 0;
    for (int i = 2; i < s.length() - 1; i++) {
        if (s[i] == 'C') {
            c++;
        }
    }
    if (c != 1) {return false;}

    int upper = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] >= 'A' && s[i] <= 'Z') {
            upper++;
        }
    }
    if (upper != 2) {
        return false;
    }

    return true;
}

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

    if (check(s)) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }

    return 0;
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  vector<P> v;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    v.pb(P(a, b));
  }

  sort(ALL(v));
  reverse(ALL(v));

  cout << v[0].first + v[0].second << endl;

  return 0;
}


Measured memory_bytes: 2420
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
d = [0] * K
A = []
for i in range(K):
    d[i] = int(input())
    A.append(list(map(int, input().split())))

visited = [False] * N
for i in range(K):
    for j in range(d[i]):
        visited[A[i][j]-1] = True

print(visited.count(False))


Measured memory_bytes: 9264
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
int a;
char op;
int b;
cin >> a >> op >> b;
if(op == '+')cout << a + b << endl;
else cout << a - b << endl;
}

Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())

V = [list(map(int, input().split())) for _ in range(M)]

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

ans = 0
for i in range(N):
    for j in range(i+1, N):
        uf = UnionFind(N)
        for a, b in V:
            if a-1 == i and b-1 ==j:
                continue
            uf.union(a-1, b-1)
        if not uf.same(i, j):
            ans += 1
print(ans)


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for (int i = 1; i <= 9; ++i) {
		if (N <= i * 111) {
			cout << i * 111 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int h = sc.nextInt();
		int w = sc.nextInt();

		char[][] array = new char[h][w];
		int[][] cal = new int[h][w];
		
		//初期化
		for(int i=0; i < h; i++){
		    String line = sc.next();
		    for(int j=0; j < w; j++){
		        array[i][j]=line.charAt(j);
		        cal[i][j]=0;
		    }
		}
		
		//計算
		for(int i=0; i < h; i++){
		    for(int j=0; j < w; j++){
		        if(array[i][j]=='#'){
		          //上があるなら
		          if(i!=0){
		              if(j!=0){cal[i-1][j-1] += 1;}
		              if(j!=w-1){cal[i-1][j+1] += 1;}
		              cal[i-1][j] += 1;
		          }
		          //下があるなら
		          if(i!=h-1){
		              if(j!=0){cal[i+1][j-1] += 1;}
		              if(j!=w-1){cal[i+1][j+1] += 1;}
		              cal[i+1][j] += 1;
		          }
		          
		          //左があるなら
		          if(j!=0){
		              cal[i][j-1] += 1;
		          }
		          
		          //右があるなら
		          if(j!=w-1){
		              cal[i][j+1] += 1;
		          }    
		        }
		    }
		}

        //出力
		for(int i=0; i < h; i++){
		    for(int j=0; j < w; j++){
		       if(array[i][j]=='#'){
		          System.out.print(array[i][j]);
		       } else {
		          System.out.print(cal[i][j]); 
		       }
		    }
		    System.out.println("");
		}
	}
}

Measured memory_bytes: 23764
n,x = map(int,input().split())
if x == 1 or x == 2*n-1:
  print("No")
else:
  print("Yes")
  ans = [0]*(2*n-1)
  if x == 2:
    ans[n-3],ans[n-2],ans[n-1],ans[n] = 4,2,1,3
    t = 5
    for i in range(2*n-1):
      if ans[i]:
        continue
      ans[i] = t
      t += 1
  else:
    ans[n-3],ans[n-2],ans[n-1],ans[n] = 1,x+1,x,2
    t = 3
    if x <= t <= x+1:
      t = x+2
    for i in range(2*n-1):
      if ans[i]:
        continue
      ans[i] = t
      t += 1
      if t == x:
        t += 2
  for x in ans:
    print(x)
      

Measured memory_bytes: 12436
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<ll> a(N), s1(N);
    ll s = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        s += a[i];
        s1[i] = s;
    }

    ll diff = 1e+10;
    for (int i = 0; i < N-1; i++) diff = min(diff, abs(s1[i] - (s-s1[i])));
    
    cout << diff << endl;
}

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

using namespace std;
int main(void) {
    int n; cin >> n;
    long long k; cin >> k;
    int q; cin >> q;
    vector<long long> point(n);
    fill(point.begin(), point.end(), k-q);

    for(int i = 0; i < q; ++i) {
        int a; cin >> a;
        point[a-1]++;
    }

    for(auto v : point) {

        if(v<=0.0) {
            cout << "No" <<endl;
        }else {
            cout << "Yes" <<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1408
from sys import stdin
N,M = map(int,input().split())
a = [int(stdin.readline()) for _ in range(M)]
A = [0]*(N+1)
mod = 1000000007
A[0] = 1
A[1] = 1
for i in a:
  A[i] = -1
if A[1] == -1:
  A[1] = 0
if not(1 in a):
  A[1] = 1
for i in range(2,N+1):
    if A[i] == -1:
      A[i] = 0
    else:
      A[i] = (A[i-2] + A[i-1]) % mod
print(A[N])

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

#define N 222

int n, d[N];
vector <int> adj[N];

int solve(int x) {
    for (int i = 1; i <= n; i ++) d[i] = 0;
    d[x] = 1;
    queue <int> Q; Q.push(x);
    while (!Q.empty()) {
        int u = Q.front(); Q.pop();
        for (auto v : adj[u]) {
            if (!d[v]) d[v] = d[u] + 1, Q.push(v);
            else if (d[v] == d[u]) return -1;
        }
    }
    int rlt = 0;
    for (int i = 1; i <= n; i ++) rlt = max(rlt, d[i]);
    return rlt;
}

char s[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++) {
        scanf("%s", s + 1);
        for (int j = 1; j <= n; j ++) {
            if (s[j] > '0') adj[i].push_back(j);
        }
    }
    int ans = -1;
    for (int i = 1; i <= n; i ++) ans = max(ans, solve(i));
    printf("%d\n", ans);
}


Measured memory_bytes: 512
N = int(input())
lst = []
result = 0
for i in range(N):
    a,b = [i for i in input().split(' ')]
    if a == b: lst.append("Y")
    else : lst.append("N")
for i in range(1,len(lst)-1):
    if lst[i] == 'Y':
        if lst[i-1]=='Y' and lst[i+1] == 'Y':
            result = 1
            print('Yes')
            break
    else :continue
if result != 1: print('No')

Measured memory_bytes: 9224
l = input().split()
c = []
t = []
for i in range(int(l[0])):
    c1,t1 = [int(i) for i in input().split()]
    c.append(c1)
    t.append(t1)
cost = 10000
for i in range(int(l[0])):
    if t[i] <= int(l[1]):
        if c[i] <= cost:
            cost = int(c[i])
if cost == 10000:
    print('TLE')
else:
    print(cost)

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

using namespace std;

typedef long long ll;
typedef pair<int, int > pi;
typedef vector<ll> vi;

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define FOR(a ,b) for(int i = a; i < b; i++) 
#define e "\n"
const ll INF = 1e18L + 5;

int main(){
	int n , W;
	cin >> n >> W;
	vector<int> weight(n), value(n);
	int sum_val = 0;
	for(int i = 0 ; i < n;i++){
		cin >> weight[i] >> value[i];
		sum_val += value[i];
	}
	
	
	vector<ll> dp(sum_val+1, INF);
	
	dp[0] = 0;
	
	for(int item = 0; item < n;item++){
		for(int val = sum_val - value[item]; val >=0 ; val--){
			dp[val+value[item]] = min(dp[val+value[item]], 
									dp[val]+weight[item]);
		}
	}
	ll ans = 0;
	for(int i = 0; i <= sum_val; i++){
		if(dp[i] <= W) ans = max(ans, (ll)i);
	}
	cout << ans << e;
}


Measured memory_bytes: 1024
h,w =list(map(int,input().split()))
s=[""]*h
for i in range(h):
    s[i]=input()
for i in range(w+1):
    print("#",end="")
print("#")

for i in range(h):
    print("#",end="")
    print(s[i],end="")
    print("#")
for i in range(w+1):
    print("#",end="")
print("#")


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int house[4][3][10];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, b, f, r, v;
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>b>>f>>r>>v;
        house[b-1][f-1][r-1]+=v;
    }
    for(int i=0; i<4; i++) {
        if(i) cout<<"####################\n";
        for(int j=0; j<3; j++) {
            for(int k=0; k<10; k++) {
                cout<<' '<<house[i][j][k];
            }
            cout<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;




int main(){
	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5]) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

ll n, a, b, c, d;
string str;

bool check (ll l, ll r)
{
    ll i = l;
    while (i < r)
    {
        if ((i + 1) < n && str[i + 1] == '.')  i++;
        else
            if ((i + 2) < n && str[i + 2] == '.') i += 2;
        else    break;
    }
    if (i == r)  return true;
    return false;
}

int main()
{
    cin >> n >> a >> b >> c >> d;
    cin >> str;
    a--;    b--;    c--;    d--;
    vector<bool>flg (n + 1, false);

    if (check (a, c) && check (b, d))
    {
        if (c < d)
            cout << "Yes";
        else
        {
            ll i = a;
            flg[i] = true;
            while (i < c)
            {
                if ((i + 1) != c && (i + 2) < n && str[i + 2] == '.')
                {
                    i += 2;
                    flg[i] = true;
                }
                else
                    if ((i + 1) < n && str[i + 1] == '.')
                    {
                        i += 1;
                        flg[i] = true;
                    }
            }
            i = b;
            ll tmp_flg = 0;
            while (i < d)
            {
                if ((i + 1) < n && str[i + 1] == '.')
                {
                    if (flg[i] == false || flg[i + 1] == false)
                    {
                        tmp_flg = 1;
                        break;
                    }
                    i += 1;
                }
                else
                    if ((i + 2) < n && str[i + 2] == '.')
                    {
                        if (flg[i] == false || flg[i + 2] == false)
                        {
                            tmp_flg = 1;
                            break;
                        }
                        i += 2;
                    }
            }
            if (tmp_flg) cout << "Yes";
            else        cout << "No";
        }
    }
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 640
nb=int(input())
liste = [int(x) for x in input().split()]
liste2= [0]*((10**5)+1)
for loop in range(len(liste)):
  liste2[liste[loop]] +=1
nba = int(input())
somme = sum(liste)
for loop in range(nba):
  n,r = map(int,input().split())
  roger = liste2[n]
  diff = r-n
  somme += diff * roger
  liste2[r] += liste2[n]
  liste2[n] = 0
  print(somme)

Measured memory_bytes: 20568
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
int x,y,z,a,b,c;
cin >> x >> y >> z;
a = x;b = y;c = z;
swap(a,b);
swap(a,c);
 cout << a << " " << b << " " << c <<endl;
return 0;

}


Measured memory_bytes: 764
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

import std.math;

void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]).sort();

    auto amax = a.reduce!max;
    int r = -1;
    auto dif = 10^^9 + 1;

    foreach (i ; 0 .. n - 1) {
        if (min(abs(amax / 2 - a[i]), abs((amax + 1) / 2 - a[i])) < dif) {
            dif = min(abs(amax / 2 - a[i]), abs((amax + 1) / 2 - a[i]));
            r = a[i];
        }
    }

    writefln("%d %d", amax, r);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4368
#include "iostream"
#include "vector"
#include "string"
#include <iomanip>

const double PI = 3.14159265358979323846;

using namespace std;

int main() {
	int A,B,H,M;
	cin >> A >> B >> H >> M;

	long double xa = A * sin(2 * PI * (H + M/60.) / 12);
	long double ya = A * cos(2 * PI * (H + M/60.) / 12);

	long double xb = B * sin(2 * PI * M / 60);
	long double yb = B * cos(2 * PI * M / 60);

	long double X = pow(xb -xa, 2.0);
	long double Y = pow(yb- ya, 2.0);
	long double L = sqrt(X + Y);
		//double L = sqrt(pow(xa - xb, 2.0)+ pow(ya - yb, 2.0));

	cout << fixed << setprecision(32) << L;


	return 0;
}

Measured memory_bytes: 3640