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

public class Main 
{
	static int[][] grid;
	static int x0, y0, n, m, maxx, maxy;
	static boolean debug = false;
	
	static void printout()
	{
		System.out.println("PRINTOUT: " + maxx + " " + maxy);
		for(int y = maxy-1; y >= y0; y--)
		{
			for(int x = x0; x < maxx; x++)
			{
				System.out.print(grid[x][y]);
			}
			System.out.print("\n");
		}
	}
	
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		while(true)
		{
			n = sc.nextInt();
			if(n == 0)break;
			m = sc.nextInt();
			int foldings = sc.nextInt();
			int punchings = sc.nextInt();
			int r = 0;
			
			grid = new int[n*20][m*20];
			x0 = 0;
			y0 = 0;
			maxx = n;
			maxy = m;
			
			for(int x = 0; x < n; x++)
			{
				for(int y = 0; y < m; y++)
				{
					grid[x][y] = 1;
				}
			}
			
			for(int i = 0; i < foldings; i++)
			{
				if(debug)System.out.println("Fold " + i);
				int foldtype = sc.nextInt();
				int foldpos = sc.nextInt();
				
				if(foldtype == 1) //vertical
				{
					int foldx = foldpos + x0;
					int width = foldx - x0;
					//width -> panjang yang termasuk
					//x0, y0 masih termasuk
					//x0 ~ foldx -> foldx ~ foldx + width
					
					for(int x = x0; x < foldx; x++)
					{
						int dist = foldx - x - 1;
						int x2 = foldx + dist;
						maxx = Math.max(maxx, x2+1);
						for(int y = y0; y < maxy; y++)
						{
							grid[x2][y] += grid[x][y];
							
							//System.out.println(x + " " + y + " -> " + x2 + " " + y );
						}
					}
					
					x0 = foldx;
				}
				else if(foldtype == 2) //horixontal
				{
					int foldy = foldpos + y0;
					int height = foldy - y0;
					//width -> panjang yang termasuk
					//x0, y0 masih termasuk
					//x0 ~ foldx -> foldx ~ foldx + width
					
					for(int y = y0; y < foldy; y++)
					{
						int dist = foldy - y - 1;
						int y2 = foldy + dist;
						maxy = Math.max(maxy, y2+1);
						for(int x = x0; x < maxx; x++)
						{
							grid[x][y2] += grid[x][y];
							
							//System.out.println(x + " " + y + " -> " + x + " " + y2 );
						}
					}
					
					y0 = foldy;
				}
				if(debug)printout();				
			}
			
			if(debug)System.out.println("Punch:");
			for(int i = 0; i < punchings; i++)
			{
				int x = sc.nextInt();
				int y = sc.nextInt();
				System.out.println(grid[x+x0][y+y0]);
			}
		}
	}

}



Measured memory_bytes: 63964
from collections import deque
N=int(input())
lst=[[] for i in range(N)]
for i in range(N-1):
    U,V,W=map(int,input().split())
    lst[U-1].append([U-1,V-1,W])
    lst[V-1].append([V-1,U-1,W])

ans_lst=[-1]*N
queue=deque([])
for i in lst[0]:
    queue.append(i)
ans_lst[0]=0
while queue:
    u,v,w=queue.popleft()
    if ans_lst[v]==-1:
        ans_lst[v]=(ans_lst[u]+w)%2
        for i in lst[v]:
            queue.append(i)

for i in ans_lst:
    print(i)

Measured memory_bytes: 109388
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        sc.close();

        long money = 100;
        long i = 1;
        for (;; i++) {
            money = money + (long) (money * 0.01);
            if (money >= A) {
                break;
            }
        }

        System.out.println(i);

    }
}


Measured memory_bytes: 35800
/*
 *  * main.cpp
 *   *
 *    */

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<cassert>
using namespace std;

long long dp[200003][3];
int n, l, r;
int C[129];
int MOD = 1000000007;
char s[300005];
int ss[28];
int main() {

    int A, B;
    scanf("%d%d", &A, &B);
    printf("%d\n", A ^ B ^ 1 ^ 2 ^ 3);

    return 0;
}


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

	vector<int> a(n);

	for (i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	for (i = 0; i < n - 1; i++)
	{
		for (j = i + 1; j < n; j++)
		{
			if (a.at(i) < a.at(j))
			{
				tmp = a.at(i);
				a.at(i) = a.at(j);
				a.at(j) = tmp;
			}
		}
	}
	tmp = a.at(0);
	cnt = 1;
	for (i = 1; i < n; i++)
	{
		if (tmp > a.at(i))
		{
			tmp = a.at(i);
			cnt++;
		}
	}
	cout << cnt << endl;
}



/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  vector<int64_t>sum(N+1);
  sum[0]=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum[i+1]=sum[i]+a[i];
  }
  sort(sum.begin(),sum.end());
  int64_t ans=0,cnt=0;
  for(int i=0;i<=N;i++){
   cnt++;
   if(i==N||sum[i]!=sum[i+1]){
     ans+=cnt*(cnt-1)/2;
     cnt=0;
   }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ma=-1,i;
  cin>>n;
  vector<int> a(n);
  vector<pair<int,int>> b(n-1);
  for(i=0;i<n;i++){
    cin>>a.at(i);
    if(ma<a.at(i)) ma=a.at(i);
  }
  sort(a.begin(),a.end());
  for(i=0;i<n-1;i++) b.at(i)=make_pair(abs(ma/2-min(a.at(i),ma-a.at(i))),a.at(i));
  sort(b.begin(),b.end());
  cout<<ma<<' '<<b.at(0).second<<endl;
}

Measured memory_bytes: 4504
/*input
3199
pink
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
 ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll sub(ll x,ll y){
    return (x % MOD - y % MOD + MOD) % MOD;
}
ll mult(ll a,ll b) 
{ 
    ll res = 0; 
    if(b<=0) return 0;
    a %= MOD; 
  
    while (b) 
    { 
        if (b & 1) 
            res = (res + a) % MOD; 
        a = (2LL * a) % MOD; 
    } 
  
    return res; 
} 
ll inv(ll z){
    if(z==1) return 1;
    return (MOD-MOD/z)*inv(MOD%z)%MOD;
}
int arr[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200) cout<<s;
    else cout<<"red";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include"custom_header.h"
#else
#define openfile 
#endif
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define vl vector<ll>
#define sz(x) (ll)x.size()
#define vvl vector<vl>
#define vpl vector<pll>
const ll mod = 1000000007;
void solve()
{
    ll n,k,i,j;cin>>n>>k;
    vl arr(n);
    fo(0,i,n)
    {
        cin>>arr[i];
    }
    fo(k,i,n)
    {
        cout<<(arr[i]>arr[i-k]?"Yes":"No")<<endl;
    }
}
int main()
{
    openfile;fastio;
    ll T = 1; //cin>>T;
    while(T--)
    {solve();}
}

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


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, k, now, ans;
vector<ll> s[110000];
vector<P> list;
priority_queue<ll, vector<ll>, greater<ll>> q;
int main() {
	cin >> n >> k;
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		s[a - 1].push_back(b);
	}
	REP(i, n) sort(ALL(s[i]));
	REP(i, n) {
		if (!s[i].empty()) {
			list.push_back(P(s[i].back(), i));
			s[i].pop_back();
		}
	}
	sort(ALL(list), greater<P>());
	REP(i, k) {
		if (list.size() <= i) continue;
		now += list[i].first;
		REP(j, s[list[i].second].size()) {
			q.push(s[list[i].second][j]);
			now += s[list[i].second][j];
		}
		while (q.size() > k - i - 1) {
			now -= q.top();
			q.pop();
		}

		ans = max(ans, now + (i + 1) * (i + 1));
	}
	cout << ans << endl;
}


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

int main(void)
{
	const int N=10000000;
	static bool isPrime[N];
	for(int i=0; i<N; i++)
		isPrime[i] = true;

	isPrime[0]=isPrime[1]=false;
	for(int i=2; i*i<=N; i++)
	{
		if(isPrime[i])
		{
			for(int j=i*2; j<N; j+=i)
				isPrime[j]=false;
		}
	}

	while(1)
	{
		int n;
		cin >> n;
		if(n==0)break;

		for(int i=n; i>=13; i--)
		{
			if(isPrime[i]   && isPrime[i-2] &&
			   isPrime[i-6] && isPrime[i-8] )
			{
				cout << i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 10924
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int x=0,fh=1; char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') fh=-1;
	for (;isdigit(ch);ch=getchar()) x=x*10+(ch^48);
	return x*fh;
}
const int N=1005;
int cnt,e,head[N],nex[N*N],to[N*N],vis[N],mat[N];
void add(int x,int y){
	to[++e]=y; nex[e]=head[x]; head[x]=e;
}
bool dfs(int x){
	int y;
	for(int i=head[x];i;i=nex[i]){
		y=to[i];
		if (vis[y]<cnt){
			vis[y]=cnt;
			if (!mat[y]||dfs(mat[y])){
				mat[y]=x; return 1;
			}
		}
	}
	return 0;
}
int a[105][2],b[105][2];
int main(){
	int n=read();
	For(i,1,n) a[i][0]=read(),a[i][1]=read();
	For(i,1,n) b[i][0]=read(),b[i][1]=read();
	int ans=0;
	For(i,1,n)
		For(j,1,n) if (a[i][0]<=b[j][0]&&a[i][1]<=b[j][1]) add(i,j);
	For(i,1,n){
		cnt=i; if (dfs(i)) ++ans; 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int mod = 1e9 + 7 ;
ll qmi(ll a , ll b)
{
  ll res = 1 ;
  while(b)
  {
    if(b & 1) res = res * a % mod;
    a = a * a % mod ;
    b >>= 1 ;
  }
  return res ;
}
ll C(ll n , ll a)
{
  ll res = 1 , ans = 1 ;
  for(ll i = 1 ; i <= a ;i ++)
   res =  res * i % mod , ans = ans * ((n - i + 1)) % mod ;
  return ans * qmi(res , mod - 2) % mod ;
}
int main()
{
  ll n , a , b ;
  cin >> n >> a >> b ;
  cout << ((qmi(2 , n) - 1 - C(n , a) - C(n , b) )% mod + mod ) % mod << endl ;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
 
int main() {
	int N;
	ll K;
	int Q;
	cin >> N >> K >> Q;
	int A[Q+3];
	ll ten[N+3];
	for (int i = 1; i < Q+1; i++) cin >> A[i];
	for (int i = 1; i < N+1; i++) ten[i] = K;
	for (int i = 1; i < Q+1; i++){
		ten[A[i]]++;  
	}
	for (int j = 1; j < N+1; j++){
		ten[j] = ten[j]-Q;
	}	
	for (int i = 1; i < N+1; i++){
		if(ten[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1792
def solve(N, As):
    ans = 1
    _As = sorted(As)
    border = 10 ** 18
    for a in _As:
        ans *= a
        if ans > border:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    N = int(input())
    As = [int(i) for i in input().split()]
    solve(N, As)


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

typedef long long ll;

int main() {
    string s; cin >> s;
    int n = s.size();
    int nn = n-1;

    ll ans = 0;
    for(int mask=0; mask<(1<<nn); mask++) {
        ll sum=0, cur=0;
        for(int i=0; i<n; i++) {
            if(mask & (1<<(i-1))) {
                // + を i, i+1 にいれる
                sum += cur;
                cur = 0;
            }
            cur = cur*10 + (s[i] - '0');
        }
        sum += cur;
        ans += sum;
    }
    
    cout << ans << "\n";

    return 0;
}

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, 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) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#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
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr 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);
  };
} Accelerate_Cin;

signed main() {
  int N, X;
  cin >> N >> X;
  static int sum[303030];
  sum[0] = 0;
  for (int i = 1; i <= N; i++) {
    int t;
    cin >> t;
    sum[i] = sum[i - 1] + t;
  }

  int ans = INF;
  for (int t = 1; t <= N; t++) {
    int tmp = (N + t) * X;
    int now = N;
    tmp += sum[now] * 5;
    now -= t * 2;
    while (now > 0) {
      tmp += 2 * sum[now];
      now -= t;

      if (tmp < 0) {
        tmp = INF;
        break;
      }
    }

    ans = min(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
def main():
    a, b = map(int, input().split())
    print(calc(a - 1) ^ calc(b))


def calc(n):
    if n % 2 == 1:
        if (n - 1) // 2 % 2 == 1:
            return 0
        else:
            return 1
    if n // 2 % 2 == 0:
        return n
    else:
        return n + 1


main()


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

using namespace std;

typedef long long ll;



int main()
{
    ios_base::sync_with_stdio(0);
    
    ll n,m;
    cin>>n>>m;
    ll ans=0;
    ans = min(n,m/2);
    n-=ans;
    m-=2*ans;
    ans+=(m/4);
    cout<<ans;
}

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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < (1 << (s.size() - 1)); i++) {
        int sum = s[0] - '0';
        string mark = "";
        for (int j = 0; j < s.size() - 1; j++) {
            if (i & (1 << j)) {
                sum += s[j + 1] - '0';
                mark += '+';
            } else {
                sum -= (s[j + 1] - '0');
                mark += '-';
            }
        }
        if (sum == 7) {
            cout << s[0] << mark[0] << s[1] << mark[1] << s[2] << mark[2]
                 << s[3] << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	if((abs(a-c)<=d)||((abs(a-b)<=d)&&(abs(c-b)<=d)))
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

fn main() {
    input! {
        a: [[u64;3];3 ],
        n: usize,
        b:[u64;n],
    }

    let mut ans = false;
    let mut sh = vec![vec![false; 3]; 3];

    for i in 0..3 {
        for j in 0..3 {
            if b.contains(&a[i][j]) {
                sh[i][j] = true;
            }
        }
    }

    for i in 0..3 {
        if sh[i][0] && sh[i][1] && sh[i][2] {
            ans = true;
        }
    }

    for i in 0..3 {
        if sh[0][i] && sh[1][i] && sh[2][i] {
            ans = true;
        }
    }

    if sh[0][0] && sh[1][1] && sh[2][2] {
        ans = true;
    }

    if sh[0][2] && sh[1][1] && sh[2][0] {
        ans = true;
    }

    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    let s1 = scan!();

    if s == s1.chars().rev().collect::<String>() && s.chars().rev().collect::<String>() == s1 {
        println!("YES")
    } else {
        println!("NO")
    }
}


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

const int INF = 1 << 29;
using ll = long long int;
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; ++i)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)


int main() {
	int n;
	cin >> n;
	bool b = false;
	rep(i, 9) {
		rep(j, 9) {
			if ((i + 1) * (j + 1) == n) {
				b = true;
				break;
			}
		}
	}

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

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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> d(N);
  for (auto& d_i: d) {
    cin >> d_i;
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      sum += d.at(i) * d.at(j);
    }
  }
  cout << sum << endl;
}

void answer2() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  int wa = 0;
  int nijo_wa = 0;
  for (int i = 0; i < N; i++) {
    int d_i;
    cin >> d_i;
    wa += d_i;
    nijo_wa += d_i * d_i;
  }

  // (a + b + c)^2 = a^2 + b^2 + c^2 + 2ab + 2bc + 2ca
  int result = ((wa * wa) - nijo_wa) / 2;
  cout << result << endl;
}


int main() {
  //answer1();
  answer2();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll n, m;
vector<ll> to[100];
vector<ll> path;
map<P, ll> edgeId;

void dfs(ll cv, ll par, ll dst, ll val, ll constraintId) {
  if (cv == dst) {
    path[constraintId] = val;
    return;
  }
  for (ll nv : to[cv]) {
    if (nv == par) {
      continue;
    }
    ll ad = (1LL << edgeId[{cv, nv}]);
    dfs(nv, cv, dst, val + ad, constraintId);
  }
}

ll cntOnes(ll x) {
  ll res = 0;
  REP(i, 50) {
    if ((1LL << i) & x) {
      res++;
    }
  }
  return res;
}

int main() {
  cin >> n;
  REP(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
    edgeId[{a, b}] = edgeId[{b, a}] = i;
  }
  cin >> m;
  path = vector<ll>(m, 0);
  REP(i, m) {
    ll u, v;
    cin >> u >> v;
    u--, v--;
    dfs(u, -1, v, 0, i);
  }

  ll ans = 0;
  FOR(bit, 1, 1LL << m) {
    ll d = 0;
    REP(i, m) {
      if ((1LL << i) & bit) {
        d |= path[i];
      }
    }
    ans += (1LL << (n - 1 - cntOnes(d))) * (cntOnes(bit) % 2 == 0 ? -1 : 1);
  }
  ans = (1LL << (n - 1)) - ans;
  cout << ans << endl;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func main() {
	var n float64
	fmt.Scan(&n)
	li := make([]float64, 5)
	min := 1000000000000001.0
	for i := 0; i < 5; i++ {
		fmt.Scan(&li[i])
		if min > li[i] {
			min = li[i]
		}
	}
	if min >= n {
		fmt.Println(5)
		return
	} else {
		fmt.Println(int(math.Ceil(n/min)) + 4)
	}
}

Measured memory_bytes: 512
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
m = max(d.values())
ans = []
for i in d:
    if d[i] == m:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 32220
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
int main(){
    int n;
    cin>>n;
    vector<int64_t> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int64_t kabu=0,money=1000;
    rep(i,n){
        if(i==0 && a[i]<a[i+1]){
            kabu += money/a[i];
            money -= a[i]*(money/a[i]);
        }
        else if(i!=0 && i!=n-1 && a[i-1]>=a[i] && a[i]<a[i+1]){//ここで買う
            kabu += money/a[i];
            money -= a[i]*(money/a[i]);
        }
        else if(i!=0 && i!=n-1 && a[i-1]<=a[i] && a[i]>a[i+1]){//ここで売る 
            money += kabu*a[i];
            kabu = 0;
        }
        else if(i==n-1){
            money += kabu*a[i];
            kabu = 0;
        }
    }
    cout<<money<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n;
	cin >> n;
	int a[100010];
	int x;
	rep(i, n) cin >> x, a[i]=x-1;
	int ans=0;
	int tmp=0;
	rep(i, n)
	{
		if(a[i]!=i) ans+=(tmp+1)/2, tmp=0;
		else tmp++;
	}
	ans+=(tmp+1)/2;
	cout << ans << endl;
	return 0;
}

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

int vx[4]={0,1,0,-1};
int vy[4]={1,0,-1,0};

int main(){
	int n,m;
	
	
	while(cin>>n>>m,n){
		char MA[102][102];
		int co[102][102];
		queue<int>pX;
		queue<int>pY;
		queue<int>sX;
		queue<int>sY;
		
		for(int i=0;i<102;i++)for(int j=0;j<102;j++)MA[i][j]='.',co[i][j]=-1;
		for(int i=1;i<=m;i++){
			for(int j=1;j<=n;j++){
				cin>>MA[j][i];
				if(MA[j][i]=='&'){
					pX.push(j);
					pY.push(i);
					co[j][i]=0;
				}
			}
		}
		
		while(co[0][0]==-1){
			if(pX.empty()==0){
				int x=pX.front(),y=pY.front();
				
				for(int i=0;i<4;i++){
					if(0<=x+vx[i]&&x+vx[i]<=n+1&&0<=y+vy[i]&&y+vy[i]<=m+1){
						if(co[x+vx[i]][y+vy[i]]==-1){
							if(MA[x+vx[i]][y+vy[i]]=='.'){
								pX.push(x+vx[i]);
								pY.push(y+vy[i]);
								co[x+vx[i]][y+vy[i]]=co[x][y];
							}
							else{
								sX.push(x+vx[i]);
								sY.push(y+vy[i]);
								co[x+vx[i]][y+vy[i]]=co[x][y]+1;
							}
						}
					}
				}
				pX.pop();
				pY.pop();
			}
			else{
				int x=sX.front(),y=sY.front();
				
				for(int i=0;i<4;i++){
					if(0<=x+vx[i]&&x+vx[i]<=n+1&&0<=y+vy[i]&&y+vy[i]<=m+1){
						if(co[x+vx[i]][y+vy[i]]==-1){
							if(MA[x+vx[i]][y+vy[i]]=='.'){
								pX.push(x+vx[i]);
								pY.push(y+vy[i]);
								co[x+vx[i]][y+vy[i]]=co[x][y];
							}
							else{
								sX.push(x+vx[i]);
								sY.push(y+vy[i]);
								co[x+vx[i]][y+vy[i]]=co[x][y];
							}
						}
					}
				}
				
				sX.pop();
				sY.pop();
			}
		}
		cout<<co[0][0]<<endl;
	}
	
	
	
	
	
	
	
	
	
	return 0;
}


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

using edge = struct { int to, cost; };
vector<vector<edge>> tree;
vector<long long> dis;
int N, Q, K;

void Dfs(int v, int p, long long d) {
  dis[v] = d;
  for (int i = 0; i < tree[v].size(); i++) {
    if (tree[v][i].to == p)
      continue;
    Dfs(tree[v][i].to, v, d + tree[v][i].cost);
  }
}

int main() {
  cin >> N;
  vector<int> a(N - 1), b(N - 1), c(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
  }
  cin >> Q >> K;
  vector<int> x(Q), y(Q);
  for (int i = 0; i < Q; i++) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }

  tree.resize(N, vector<edge>(0, {-1,-1}));
  for (int i = 0; i < N - 1; i++)
    tree[a[i]].push_back(edge{b[i], c[i]}), tree[b[i]].push_back(edge{a[i],c[i]});

  dis.resize(N);
  Dfs(K - 1, -1, 0);

  for (int i = 0; i < Q; i++)
    cout << dis[x[i]] + dis[y[i]] << endl;
}

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

namespace TYC
{
	typedef long long ll;
	
	const int N = 1 << 18 | 5, mod = 998244353;

	int n, A[N], B[N];

	inline int read()
	{
		int x = 0, f = 0, ch = getchar();
		while (!isdigit(ch))
			f |= (ch == '-'), ch = getchar();
		while (isdigit(ch))
			x = x * 10 + ch - '0', ch = getchar();
		return f ? -x : x;
	}

	int inv(const int x) { return x == 1 ? 1 : int((ll)inv(mod % x) * (mod - mod / x) % mod); }

	void FWT(int *a)
	{
		for (int len = 1; len < n; len <<= 1)
			for (int i = 0; i < n; i += len << 1)
				for (int k = 0; k < len; k++)
				{
					int x = a[i + k], y = a[i + len + k];
					a[i + k] = (x + y) % mod;
					a[i + len + k] = (x - y + mod) % mod;
				}
	}

	void IFWT(int *a)
	{
		static const int INV2 = (mod + 1) >> 1;
		for (int len = 1; len < n; len <<= 1)
			for (int i = 0; i < n; i += len << 1)
				for (int k = 0; k < len; k++)
				{
					int x = a[i + k], y = a[i + len + k];
					a[i + k] = int((ll)(x + y) * INV2 % mod);
					a[i + len + k] = int((ll)(x - y + mod) * INV2 % mod);
				}
	}

	void work()
	{
		n = 1 << read();
		int sum = 0;
		for (int i = 0; i < n; i++)
			sum = (sum + (A[i] = read())) % mod;
		for (int i = 0, tmp = inv(sum); i < n; i++)
			A[i] = int((ll)A[i] * tmp % mod);
		A[0] = (A[0] - 1 + mod) % mod;
		for (int i = 0; i < n; i++)
			B[i] = mod - 1;
		B[0] = (n - 1 + mod) % mod;
		FWT(A), FWT(B);
		for (int i = 1; i < n; i++)
			A[i] = int((ll)B[i] * inv(A[i]) % mod);
		IFWT(A);
		for (int i = 0; i < n; i++)
			printf("%d\n", (A[i] - A[0] + mod) % mod);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 4864
n, m = [int(i) for i in input().split()]
solved = [False for _ in range(n)]
failures = [0 for _ in range(n)]

total_success = 0

for _ in range(m):
    res = input().split()
    p = int(res[0])
    if not solved[p - 1]:
        if res[1] == "AC":
            solved[p - 1] = True
            total_success += 1
        else:
            failures[p - 1] += 1

total_fail = sum([f for i, f in enumerate(failures) if solved[i]])
print(total_success, total_fail)


Measured memory_bytes: 5540
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
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);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

string chg_1(string s) {
    int N = s.size();
    string a = "";
    for(int i=0; i+1<N; i++) {
        int u = s[i] - '0', v = s[i+1] - '0';
        a += char('0' + abs(u - v));
    }
    return a;
}

string chg_2(string s) {
    // if(s.size() <= 5) return chg_1(s);
    if(s.size() % 2 == 0) return chg_1(s);
    
    int N = s.size();
    // cerr << "len = " << N << endl;
    string a = "";
    for(int i=0; i+2<N; i+=2) {
        int u = s[i] - '0', v = s[i+2] - '0';
        a += char('0' + abs(u - v));
    }
    return a;
}

int main() {
    int N; cin >> N;
    string s; cin >> s;
    N = s.size();

    int step = 0;
    // if(N % 2 == 0) {
    //     s = chg_1(s);
    //     step++;
    // }
    for(; N>1; N=s.size()) {
        s = chg_2(s);
        step++;
    }
    // cerr << step << endl;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
   /* ll t;
    cin>>t;
    while(t--)*/
    {


        ll n,m=0,sum=0;
       cin>>n;
     for(ll i=1;i<=n;i++)
     {
         if(i%15==0)
            m++;
        else if(i%3==0)
            m++;
            else if(i%5==0)
            m++;
            else
            sum+=i;
     }
     cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 3632
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, m] <- getIntList
    let ans | n == m = productMod [(productMod [1..n]), (productMod [1..m]), 2]
            | abs (n - m) == 1 = mulMod (productMod [1..n]) (productMod [1..m])
            | otherwise = 0
    print ans

moduloN = 10 ^ 9 + 7
modN = flip mod moduloN
mulMod x y = modN $ x * y
productMod xs = foldl' mulMod 1 xs

Measured memory_bytes: 380
#include<iostream>

using namespace std;

char g[10][10];
int h, w, k;
bool check(int sh, int sc){
    int cnt= 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(g[i][j] == '#' && ((1<<i) & sh) && ((1<<j) & sc)){
                cnt++;
            }
        }

    }

    return cnt ==k;
}

int main(){
    cin >>h>>w>>k;

    for(int i=0;i<h;i++)
        cin >>g[i];

    int ans =0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            if(check(i, j)){
               ans++;
            }
        }
    }

    cout << ans;
}


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

int main()
{
	 bitset<64> cpp(0);
	 int p, o, i;
	 cin >> p;
	 while (p--)
	 {
		 cin >> o;
		 switch (o) {
		 case 0:cin >> i; cout << cpp[i] << endl; break;
		 case 1:cin >> i; cpp.set(i); break;
		 case 2:cin >> i; cpp.reset(i); break;
		 case 3:cin >> i; cpp.flip(i); break;
		 case 4:cout << cpp.all() << endl; break;
		 case 5:cout << cpp.any() << endl; break;
		 case 6:cout << cpp.none() << endl; break;
		 case 7:cout << cpp.count() << endl; break;
		 case 8:cout << cpp.to_ulong() << endl; break;
		 }
	 }
	 return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define ALLC(v) v.cbegin(), v.cend()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    while (getline(cin, s))
    {
        stack<double> st;
        stringstream ss(s);
        double a, b;
        while (ss >> s)
        {
            if (s == "+" || s == "-" || s == "*" || s == "/")
            {
                a = st.top();
                st.pop();
                b = st.top();
                st.pop();
                if (s == "+")
                    st.push(a + b);
                else if (s == "-")
                    st.push(b - a);
                else if (s == "*")
                    st.push(a * b);
                else if (s == "/")
                    st.push(b / a);
            }
            else
                st.push(stod(s));
        }
        printf("%.7f\n", st.top());
    }
    return 0;
}


Measured memory_bytes: 3160
n=int(raw_input())
a=raw_input()
b=raw_input()
res = 1
i=0
s=0
M=1000000007
if a[i]==b[i] :
    res = 3
    i+=1
    s=1
else :
    res = 6
    i+=2
    s=2
while i<n :
    if a[i]==b[i] :
        if s==1 :
            res *= 2
            res %= M
        i+=1
        s=1
    else :
        if s==1 :
            res *= 2
            res %= M
        else :
            res *= 3
            res %= M
        i+=2
        s=2
print res

Measured memory_bytes: 2692
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main()
{
	string s;
	cin >> s;
	int flag = 0;
	for (int i = 0; i <= s.size(); ++i) {
		if (flag == 0) {
			if (s[i] == 'C') {
				flag = 1;
			}
		}else
			if (flag == 1) {
				if (s[i] == 'F') {
					flag = 2; break;
				}
			}
	}
	if (flag == 2) {
		cout << "Yes" << endl;

	}else{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [[int(x) for x in input().split()] for i in range(N)]
AB = sorted(AB)
sum_drink = 0
ans = 0
for i in range(N):
  if sum_drink + AB[i][1] <= M:
    ans += AB[i][0]*AB[i][1]
    sum_drink += AB[i][1]
  else:
    ans += AB[i][0]*(M-sum_drink)
    sum_drink = M
  if sum_drink == M:
    break
print(ans)

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

typedef long long ll;
int ara[4][4];
int diag=0,diag2=0,col=0,row=0;
void CheckRow(vector<int>v)
{
    for(int i=0; i<3; i++)
    {
        int r=0;
        for(int j=0; j<3; j++)
        {
            for(auto x: v)
            {
                if(ara[i][j]==x)
                {
                    r++;
                    break;
                }
            }
        }
        if(r>=3)
        {
            row++;
            break;
        }
    }
    return;
}
void CheckCol(vector<int>v)
{
    for(int i=0; i<3; i++)
    {
        int c=0;
        for(int j=0; j<3; j++)
        {
            for(auto x: v)
            {
                if(ara[j][i]==x)
                {
                    c++;
                    break;
                }
            }
        }
        if(c>=3)
        {
            col++;
            break;
        }
    }
    return;
}
void CheckDiag(vector<int>v)
{
    int d=0;
    for(int i=0; i<3; i++)
    {
        for(auto x: v)
        {
            if(ara[i][i]==x)
            {
                d++;
                break;
            }
        }
    }
    if(d>=3)
    {
        diag++;
        return;
    }
    return;
}
void CheckLeftDiag(vector<int>v)
{
    int d=0;
    for(int i=0,j=2;i<3;i++,j--)
    {
        for(auto x: v)
        {
            if(ara[i][j]==x)
            {
                d++;
                break;
            }
        }
    }
    if(d>=3)
    {
        diag2++;
        return;
    }
    return;
}
int main()
{
    for(int i=0; i<3; i++)
    {
        for(int j=0; j<3; j++)
        {
            cin>>ara[i][j];
        }
    }
    int n;
    cin>>n;
    vector<int>v(n);
    for(auto &x: v)
    {
        cin>>x;
    }
    CheckDiag(v);
    if(diag!=0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        CheckRow(v);
        if(row!=0)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            CheckCol(v);
            if(col!=0)
            {
                cout<<"Yes"<<endl;
            }
            else
            {
               CheckLeftDiag(v);
               if(diag2!=0)
               {
                   cout<<"Yes"<<endl;
               }
               else
               {
                   cout<<"No"<<endl;
               }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	while(cin>>n,n){
		vvll vv;
		initvv(vv,n,n,0LL);
		vvll a=vv,b=vv;
		rep(i,n) rep(j,n) cin>>vv[i][j];
		rep(i,n){
			ll t=LLONG_MAX;
			rep(j,n){
				t=min(t,vv[i][j]);
			}
			rep(j,n) if(vv[i][j]==t) b[i][j]=1;
			t=0;
			rep(j,n){
				t=max(t,vv[j][i]);
			}
			rep(j,n) if(vv[j][i]==t) a[j][i]=1;
		}
		bool f=false;
		ll ans=-10000000;
		rep(i,n){
			rep(j,n){
				if(a[i][j]&&b[i][j]) f=true,ans=max(ans,vv[i][j]);
			}
		}
		if(!f){
			cout<<0<<endl;
		}
		else{
			cout<<ans<<endl;
		}
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
  	cout<<fixed<<setprecision(0);
    mainmain();
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


int main()
{
  ll N;
  scanf("%lld",&N);
  ll D;
  scanf("%lld",&D);
  vector<vector<ll>> X(N, vector<ll>(D));
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      scanf("%lld",&X[i][j]);
    }
  }
  ll ans = 0;
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      double dist=0.0;
      for (int k=0; k<D; k++) {
        dist += pow(X[i][k]-X[j][k],2);
      }
      dist = sqrt(dist);
      if (ceil(dist)==floor(dist)) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
package main
  
import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
  num := []int{}
  line := nextLine()
  str := strings.Split(line, " ")

  for _, v1 := range str {
    n, _ := strconv.Atoi(v1)
    is_dupl := true

    for _, v2 := range num {
      if v2 == n {
        is_dupl = false
      }
    }

    if is_dupl {
      num = append(num, n)
    }
  }
  fmt.Println(len(num))
}
        

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

using namespace std;

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

int main(){
  int n;
  cin >> n;
  rep(a,9){
    rep(b,9){
      if(a*b==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
 
#define int long long
#define endl '\n'

#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()

#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846264338327950L
#define MOD 1000000007

int32_t main(){

    
    double t;
    cin>>t;
    cout<<(2*pi*t);
    

  return 0;
}




Measured memory_bytes: 3792
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
print((n+1)//2)

Measured memory_bytes: 38384
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
  
function main(){
  var read = 0;
  var resultCase = 1;
  while(true){
    var maxWeight = +input[read++];
    if(!maxWeight){
      break;
    }
      
    var treasures = +input[read++];
    var dp = new Array(maxWeight + 1);//new Int16Array(maxWeight + 1);
    
    for(var i = treasures; i--;){
      var c = input[read++].split(",");
      var tv = +c[0];
      var tw = +c[1];
  
      for(var w = maxWeight; w - tw >= 0; w--){
        dp[w] = max((dp[w-tw]|0) + tv, (dp[w]|0));
      }
    }
  
    var resultWeight = 1001;
    var resultCost = 0;
    for(var i = 0; i <= maxWeight; i++){
      var dpi = dp[i];
      if(dpi > resultCost){
        resultCost = dpi;
        resultWeight = i;
      }
    }
      
    console.log("Case " + resultCase++ + ":\n" + resultCost + "\n" + resultWeight);
  }
}
 
 
function max(a, b) {
  var t = a - b;
  return a - (t & (t >> 31));
}

Measured memory_bytes: 8700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,i,j;
    cin>>n>>k;
    long long int arr[n],dp[k+1];
    for(i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=2;
    for(i=1;i<=k;i++)
    {
        dp[i]=2;
        for(j=0;j<n;j++)
        {
            if(arr[j]>i)
                continue;
            if(dp[i-arr[j]]==2)
                dp[i]=1;
        }
    }
    if(dp[k]==1)
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}


Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int AB = sc.nextInt();
		int BC = sc.nextInt();
		int CA = sc.nextInt();

		out.println((BC*AB)/2);

		sc.close();

	}

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

}


Measured memory_bytes: 23124