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

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 最初の文字の固まりを整数値と想定して読み込む
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            for (int y = 0; y < H; y++) {
                for (int x = 0; x < W; x++) {
                    if((x+y)%2 == 0){ System.out.print('#');}
                    if((x+y)%2 == 1){ System.out.print('.');}
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

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

Measured memory_bytes: 256
object Main {
  def main(args:Array[String]){
    val sc=new java.util.Scanner(System.in)
    var tmp=false  
      while(true){
       val h,w=sc.nextInt
       if(tmp) println()
       if(h==0&&w==0) return
       for(i<-1 to h;j<-1 to w){
         if(j==w){
           println("#")
         }
         else print("#")
       }
       tmp=true
     }
  }
}

Measured memory_bytes: 52384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num[] = new int[6];
		int upSide, frontSide;
		for (int i = 0; i < 6; i++) {
			num[i] = sc.nextInt();
		}
		Dice d = new Dice(num);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			upSide = sc.nextInt();
			frontSide = sc.nextInt();
			d.printDiceSide(upSide, frontSide);
		}

	}
}

class Dice {
	int num[];
	int temp;

	public Dice(int num[]) {
		this.num = num;
	}

	void printDiceSide(int upSide, int frontSide) {
		while (true) {
			if (upSide == num[0] && frontSide == num[1]) {
				break;
			}

			if (upSide == num[1]) {
				rollSouth();
			} else if (upSide == num[2]) {
				rollEast();
			} else if (upSide == num[3]) {
				rollWest();
			} else if (upSide == num[4]) {
				rollNorth();
			} else if (upSide == num[5]) {
				rollSouth();
				rollSouth();
			}
			if (frontSide == num[2]) {
				rollRight();
			} else if (frontSide == num[3]) {
				rollLeft();
			} else if (frontSide == num[4]) {
				rollRight();
				rollRight();
			}
		}
		System.out.println(num[2]);
	}

	void rollWest() {
		temp = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = temp;
	}

	void rollNorth() {
		temp = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = temp;
	}

	void rollEast() {
		temp = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = temp;
	}

	void rollSouth() {
		temp = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = temp;
	}

	void rollRight() {
		temp = num[1];
		num[1] = num[3];
		num[3] = num[4];
		num[4] = num[2];
		num[2] = temp;
	}

	void rollLeft() {
		temp = num[1];
		num[1] = num[2];
		num[2] = num[4];
		num[4] = num[3];
		num[3] = temp;
	}
}

Measured memory_bytes: 26148
n = int(input())
points = []

for i in range(n):
    x, y, h = map(int, input().split())
    points.append((h, x, y))
    
points.sort(reverse=True)
    
for i in range(101):
    for j in range(101):        
        ph, px, py = points[0]
        H = ph + abs(px-i) + abs(py-j)
        if all(ph == max(H - abs(px-i) - abs(py-j), 0) for ph, px, py in points):
            print(i, j, H)

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

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (s.size() > k) {
		for (int i = 0; i < k; ++i) {
			cout << s[i];
		}
		cout << "...";
	} else {
		cout << s;
	}
}

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

using namespace std;

int main(){
 int A, B, AB = 0;
 cin >> A >> B;
 AB = A * B;
 if(AB % 2 == 0){
  cout << "No" << endl;
 }else{
  cout << "Yes" << endl;
 }
}


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

int main() {
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<vector<unsigned long>> bulb(M);
    for(auto& i : bulb){
        unsigned long k;
        cin >> k;
        i = vector<unsigned long>(k);
        for(auto& j : i){
            cin >> j;
            --j;
        }
    }
    for(auto& i : bulb){
        unsigned long p;
        cin >> p;
        if(p)i.push_back(10);
    }
    unsigned long ans{0};
    for(unsigned long i = 1024; i < 1024 + (1 << N); ++i){
        ans += [&]{
            for(auto& j : bulb){
                unsigned long cnt{1};
                for(auto& k : j)cnt ^= (i >> k) & 1;
                if(!cnt)return 0;
            }
            return 1;
        }();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;

char chair[128];
int n, m;
const int M = 2;

void A() {
	for(int i = 0; i < n; i++) {
		if(chair[i+M] == 'N') {
			chair[i+M] = 'A';
			break;
		}
	}
}

void B() {
	for(int i = n-1; i >= 0; i--) {
		if(chair[i+M] == 'N' && chair[i+1+M] != 'A' && chair[i-1+M] != 'A') {
			chair[i+M] = 'B';
			return;
		}
	}
	for(int i = 0; i < n; i++) {
		if(chair[i+M] == 'N') {
			chair[i+M] = 'B';
			return;
		}
	}
}

void C() {
	for(int i = 0; i < n; i++) {
		/*
		if(chair[i+M] == 'N' && (chair[i-1+M] != 'N' || chair[i+1+M] != 'N')) {
			chair[i+M] = 'C';
			return;
		}
		*/
		if(chair[i+M] != 'N') {
			if(chair[i+1+M] == 'N' && i+1 < n) {
				chair[i+1+M] = 'C';
				return;
			}
			else if(chair[i-1+M] == 'N' && i-1 >= 0) {
				chair[i-1+M] = 'C';
				return;
			}
		}
	}
	chair[n/2+M] = 'C';
}

void D() {
	int mx = 0;
	int indx = 0;
	for(int i = 0; i < n; i++) {
		if(chair[i+M] == 'N') {
			int mn = 1000;
			for(int j = 0; j < n; j++) {
				if(chair[j+M] != 'N') {
					if(mn > abs(j - i))
						mn = abs(j - i);
				}
			}
			if(mn > mx) {
				mx = mn;
				indx = i;
			}
		}
	}
	chair[indx+M] = 'D';
}

int main() {
	while(cin >> n >> m, n || m) {
		for(int i = 0; i < 128; i++)
			chair[i] = 'N';
		for(int i = 0; i < m; i++) {
			string s;
			cin >> s;
			if(s[0] == 'A')
				A();
			else if(s[0] == 'B')
				B();
			else if(s[0] == 'C')
				C();
			else
				D();
		}
		for(int i = 0; i < n; i++) {
			cout << (chair[i+M] == 'N' ? '#' : chair[i+M]);
		}
		cout << endl;
	}
}

Measured memory_bytes: 1196
#ABC107 B
H,W = map(int,input().split(' '))
field = []

for i in range(H):
	field.append(str(input()))

def rotate(mat):
	#転置行列を返す関数
	mat_t = []
	if mat != []:
		for i in range(len(mat[0])):
			#matのいまの列数＝転置後の行数
			mat_t.append([])
		for i in range(len(mat[0])):
			#matを横方向に走査
			for j in range(len(mat)):
				#matを縦方向に走査
				mat_t[i] += mat[j][i]
		for i in range(len(mat_t)):
			mat_t[i] = ''.join(mat_t[i])
	return mat_t

def white(n):
	return '.' * n

while white(W) in field:
    field.remove(white(W))
field_t = rotate(field)
while white(len(field_t[0])) in field_t:
    field_t.remove(white(len(field_t[0])))
field_t_t = rotate(field_t)

for s in field_t_t:
	print(s)

Measured memory_bytes: 3188
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    N = input(int)
    A = input([int, N])

    count = dd(int)
    for a in A:
        count[a] += 1
    sum_ = 0
    for k, v in count.items():
        sum_ += (v * (v - 1)) // 2
    for a in A:
        print(sum_ - count[a] + 1)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 35344
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <time.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 250
# define eps 1e-3
# define MAXM 500005
# define MOD 1000000007
# define INF 1000000000
# define MIN(a,b) (a)>(b)?(b):(a)
# define MAX(a,b) (a)<(b)?(b):(a)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;

int main()
{
    char a[15],b[15],c[15];
    cin>>a>>b>>c;
    if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}





















Measured memory_bytes: 256
s, t = gets.chomp.split(' ')  # 空白区切りする方法
a, b = gets.chomp.split(' ').map(&:to_i)
u = gets.chomp

if s == u
  a -= 1   # a の値をひとつ減算する
else
  b -= 1   # b の値をひとつ減算する
end

print(a, ' ', b)


Measured memory_bytes: 1788
package main

import (
	"fmt"
)

func main() {
	var N, L int
	fmt.Scan(&N)
	arr := make([]int, N)
	max := 0
	maxIndex := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&L)
		arr[i] = L
		if L > max {
			max = L
			maxIndex = i
		}
	}
	var total int
	for i, v := range arr {
		if i != maxIndex {
			total += v
		}
	}
	var r string
	if max < total {
		r = "Yes"
	} else {
		r = "No"
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
#define MOD 1000000007
int main(){
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  vector<ll> a(n + 5, 0);
  for(int i = 0; i <= n; i++){
    a[i + 1] += a[i] + i;
  }
  vector<ll> b(n + 5, 0);
  for(int i = 0; i <= n; i++){
    b[i + 1] += b[i] + (n - i);
  }
    for(int i = k; i <= n; i++) {
      ll maxi = b[i];
      ll mini = a[i];
      //cout << mini << " " << maxi << '\n';
      ans += maxi - mini + 1;
      if(maxi == mini){
        ans++;
      }
      ans %= MOD;
    }
  cout << (ans + 1)% MOD << endl;
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string S, T;
    cin >> S >> T;
    ll N = S.size();
    ll M = T.size();
    vector<ll> sums(N+1, 0), sumt(M+1, 0);
    REP(i, N){
    	sums[i+1] = sums[i] + (S[i] == 'A' ? 1 : 2);
    }
    REP(i, M){
    	sumt[i+1] = sumt[i] + (T[i] == 'A' ? 1 : 2);
    }
    ll q;
    cin >> q;
    REP(i, q){
    	ll a, b, c, d;
    	cin >> a >> b >> c >> d;
    	if((sums[b] - sums[a-1])%3 == (sumt[d] - sumt[c-1])%3) cout << "YES" << endl;
    	else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 2512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
#include <cassert>
#include <memory>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
signed main(){

    ll N;
    cin>>N;
    N--;
    string ans;
    while(N!=-1){
        // cout<<N<<endl;
        ans+=char(N%26  + 'a');
        N/=26;
        N--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	if(a<b)cout<<c<<endl;
	else
	{
		ll cnt = c-(a-b);
		if(cnt<0)cout<<0<<endl;
		else cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3604
N, T = map(int, input().split())
ts = list(map(int, input().split()))

ans = 0
tmp_now = ts[0] + T
tmp_start = ts[0]

for i in range(1, N):
    # print(tmp_now, tmp_start)
    if ts[i] <= tmp_now:
        tmp_now = ts[i] + T
    else:
        ans += tmp_now - tmp_start
        tmp_now = ts[i] + T
        tmp_start = ts[i]

ans += tmp_now - tmp_start

print(ans)



Measured memory_bytes: 25196
#include<stdio.h>

int main(void){
    int A,B,C,X,Y;
    int cost = 0;
    scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
    if(X<Y){
        if(A+B>=2*C){
            cost = 2*C*X;
            if(B*(Y-X)>=2*C*(Y-X)){
                cost += 2*C*(Y-X);
            }else{
                cost += B*(Y-X);
            }
        }else{
            cost = A*X+B*Y;
        }
    }else{
        if(A+B>=2*C){
            cost = 2*C*Y;
            if(A*(X-Y)>=2*C*(X-Y)){
                cost += 2*C*(X-Y);
            }else{
                cost += A*(X-Y);
            }
        }else{
            cost = A*X+B*Y;
        }
    }
    printf("%d",cost);
    return 0;
}

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


int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<ll> ans(n, 0);
  rep(i, n-1)
    for (int j=i; j<n; j++)
      ans[min(j - i, abs(i - x) + abs(j - y) + 1)]++;
  for (int i=1; i<n; i++)
    printf("%d\n", ans[i]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	int ma = -1;
	rep(i, 0, N) chmax(ma, A[i]);

	int mi = inf;
	rep(i, 0, N) chmin(mi, A[i]);

	int ans = ma - mi;
	cout << ans << endl;
}







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

using namespace std;

int main() {
	const ll MOD = 1e9 + 7;
	string s;
	cin >> s;

	vector<vector<ll>> dp(s.size() + 1, vector<ll>(4, 0));

	for (int i = s.size(); i >= 0; i--) {
		for (int j = 3; j >= 0; j--) {
			if (i == s.size()) {
				if (j == 3) dp[i][j] = 1;
				if (j < 3) dp[i][j] = 0;
			}

			if (i < s.size()) {
				if (j == 3) {
					int m = 1;
					if (s[i] == '?') m = 3;

					dp[i][j] = m * dp[i + 1][j];
					dp[i][j] %= MOD;
				}

				if (j < 3) {
					int m1 = 1, m2 = 0;
					if (s[i] == '?') {
						m1 = 3;
						m2 = 1;
					} else if (j == (int)(s[i] - 'A')) {
						m2 = 1;
					}

					dp[i][j] = m1*dp[i + 1][j] + m2*dp[i + 1][j + 1];
					dp[i][j] %= MOD;
				}
			}
		}
	}

	cout << dp[0][0] << endl;
	return 0;
}


Measured memory_bytes: 7424
import * as fs from 'fs';

const inputs = fs.readFileSync('/dev/stdin', 'utf8').split(/\n/);

const calcPrice = (n: number, k: number, x: number, y: number) => {
  const price = Math.min(k, n) * x + Math.max(0, n - k) * y;
  return price;
};

console.log(calcPrice(+inputs[0], +inputs[1], +inputs[2], +inputs[3]));


Measured memory_bytes: 29844
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int a = n / 100;
  int b = n / 10 % 10;
  int c = n % 10;
  if (a == 7 || b == 7 || c == 7) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 3624
import numpy as np
from collections import deque
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
N, K = map(int, input().split())

edges = [set() for _ in range(N)]
par = [None for _ in range(N)]
flag = [False for _ in range(N)]
neighbors = [0 for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a-1].add(b-1)
    edges[b-1].add(a-1)

q = deque()
q.append(0)




MOD= 10**9+7
res = K

while len(q) != 0:
    u = q.popleft()
    flag[u] = True
    if par[u] is not None:
        neighbors[par[u]] += 1
        if res != 0:
            res = res*(K-neighbors[par[u]])%MOD
    for v in edges[u]:
        if not flag[v]:
            par[v] = u
            neighbors[v] = 1
            q.append(v)

print(res)


Measured memory_bytes: 49416
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    
    int d, r;
    double f;
    
    d = a / b;
    r = a % b;
    f = (double)a / b;
    
    printf("%d %d %.5lf\n", d, r, f);
    return 0;
}


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

int main(){

  int n;
  scanf("%d", &n);

  char M[101][101];
  for(int i=1; i <= n; i++){
    for(int j=1; j <= n; j++){
      M[i][j] = 0;
    }
  }

  for(int i=0; i<n; i++){
    int u, k;
    scanf("%d %d", &u, &k);
    for(int j=0; j<k; j++){
      int adj;
      scanf("%d", &adj);
      M[u][adj] = 1;
    }
  }

for(int i=1; i <= n; i++){
  for(int j=1; j <= n; j++){
    if(j != n) printf("%d ", M[i][j]);
    else printf("%d\n", M[i][j]);
  }
}

  return 0;
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, n, c, d;
  c = d = 0;
  a = b = 0;
  in(n);
  string s;
  in(s);
  rep(i, n){
    if(s[i] == '(')
      a++;
    else
      b++;
    c = max(c, b - a);
    d = max(d, a - b);
  }
  rep(i, c)
    out('(');
  out(s);
  rep(i, a + c - b)
  out(')');
  memi;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff  first
#define INF 1000000001
#define inf1 1000000000000000001
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 2e5+9;
const lli mod= 1000000007;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli digit(lli n){int res=(int)log10(n)+1;return res;}
lli lcm(lli a,lli b){lli ans=(a*b)/(__gcd(a,b));return ans;}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}
///=================== ALWAYS CHECK 1 or 0 base case=================================================================================///
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------///
int n,m;
set<int>adj[maxn];
int vis[maxn];
int c;
void dfs(int curr)
{
    vis[curr]=1;
    c++;
    for(int child:adj[curr])
    {
        if(vis[child]==0)dfs(child);
    }
}
void solve()
{
    cin>>n>>m;
    while(m--)
    {
        int a,b;cin>>a>>b;
        adj[a].insert(b);adj[b].insert(a);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==0)
        {
            c=0;
            dfs(i);
            ans=max(ans,c);
        }
    }
    cout<<ans<<endl;
}
int main()
{
    solve();
}


Measured memory_bytes: 38688
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<vector<int> > edges(n);
        for(int i=0; i<m; ++i){
            int a, b;
            cin >> a >> b;
            edges[a-1].push_back(b-1);
            edges[b-1].push_back(a-1);
        }

        vector<bool> check(n, false);
        check[0] = true;
        for(int i=0; i<2; ++i){
            vector<bool> next = check;
            for(int j=0; j<n; ++j){
                if(check[j]){
                    for(unsigned k=0; k<edges[j].size(); ++k)
                        next[edges[j][k]] = true;
                }
            }
            check = next;
        }

        int ret = -1;
        for(int i=0; i<n; ++i){
            if(check[i])
                ++ ret;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>

using namespace std;

long long Fibonacci[43] = {0};

long long fibo(int n){
	if(n == 0)	return 1;
	else if(n == 1)	return 1;
	else{
		if(Fibonacci[n-1] != 0 && Fibonacci[n-2] != 0){
			//Do nothing
		}else if(Fibonacci[n-1] != 0){
			Fibonacci[n-2] = fibo(n-2);
		}else if(Fibonacci[n-2] != 0){
			Fibonacci[n-1] = fibo(n-1);
		}else{
			Fibonacci[n-1] = fibo(n-1);
			Fibonacci[n-2] = fibo(n-2);
		}
		return Fibonacci[n-1] + Fibonacci[n-2];
	}
}

int main(){
	int n;
	scanf("%d",&n);
	printf("%lld\n",fibo(n));
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	int W, a, b;
	cin >> W >> a >> b;

	if (a + W < b)cout << b - (a + W) << endl;
	else if (b + W >= a&&a + W >= b)cout << 0 << endl;
	else cout << a - (b + W) << endl;

	return 0;
}

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

using namespace std;

int main()
{
    vector<int> ant;

    for(int i = 0; i < 5; ++i)
    {
        int a;
        cin >> a;
        ant.push_back(a);
    }
    int k;
    cin >> k;


    for(int i = 0; i < 5; ++i)
    {
        for(int j = i+1; j < 5; ++j)
        {
            if(abs(ant[j]-ant[i]) > k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << "\n";

    return 0;
}


Measured memory_bytes: 256
r, c, k = map(int, input().split())

atlas = [[0]*c for i in range(r)]
dp = [[[0]*c for i in range(r)] for j in range(4)]

for i in range(k):
  x, y, v = map(int, input().split())
  atlas[x-1][y-1] = v
  
def max_sum(r, c, atlas):
  global dp

  if atlas[0][0] > 0:
    dp[1][0][0] = atlas[0][0]
    
  for i in range(r):
    for j in range(c):
      for h in range(4):
        
        if j+1 < c:
          dp[h][i][j+1] = max(dp[h][i][j+1], dp[h][i][j])
          if atlas[i][j+1] > 0 and h < 3:
            dp[h+1][i][j+1] = max(dp[h+1][i][j+1], dp[h][i][j]+atlas[i][j+1])
            
        if i+1 < r:
          dp[0][i+1][j] = max(dp[0][i+1][j], dp[h][i][j])
          if atlas[i+1][j] > 0:
            dp[1][i+1][j] = max(dp[1][i+1][j], dp[h][i][j]+atlas[i+1][j])
          
            
  return dp

max_sum(r, c, atlas)

ans = 0
for i in range(4):
  ans = max(ans, dp[i][r-1][c-1])
  
print(ans)

Measured memory_bytes: 430540
#!/usr/bin/env python
# coding: utf-8

# In[7]:


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


# In[8]:


ave = sum(X)//len(X)
ans_1 = sum([(x-ave)**2 for x in X])
ans_2 = sum([(x-(ave+1))**2 for x in X])
print(min(ans_1, ans_2))


# In[ ]:






Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define nmax 500005
#define oo 1000000007
#define reset(x, y) memset(x, y, sizeof (x))
#define s second
#define f first
#define PB(x) push_back(x)
#define Task ""
#define For(i, x, y) for(int i = x; i <= y; i++)
#define Fod(i, x, y) for(int i = x; i >= y; i--)
#define FOR(i, x) for(int i : x)

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vti;
typedef vector<vti> vtv;
typedef vector<ll> vli;

string s;
int n;
vti e[nmax];
int deg[nmax];
int Q[nmax];

void Enter()
{
    cin >> s;
    n = s.length();
    s = ' ' + s;
    reset(deg, 0);
    For(i, 1, n)
        if(s[i] == '<') {
            e[i].PB(i + 1);
            deg[i + 1]++;
        }
        else {
            e[i + 1].PB(i);
            deg[i]++;
        }
}

void Solve()
{
    queue<int> q;
    For(i, 1, n + 1)
        if(!deg[i])
            q.push(i);
    int dem = 0;
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        for(int v : e[u]) {
            Q[v] = Q[u] + 1;
            q.push(v);
        }
    }
    ll res = 0;
    For(i, 1, n + 1)
        res += Q[i];
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    Enter();
    Solve();
}


Measured memory_bytes: 32048
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x)
            if isinstance(other, ModInt)
            else ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x)
            if isinstance(other, ModInt)
            else ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x)
            if isinstance(other, ModInt)
            else ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(self.x * pow(other.x, MOD - 2, MOD))
            if isinstance(other, ModInt)
            else ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD))
            if isinstance(other, ModInt)
            else ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x)
            if isinstance(other, ModInt)
            else ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(other.x * pow(self.x, MOD - 2, MOD))
            if isinstance(other, ModInt)
            else ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD))
            if isinstance(other, ModInt)
            else ModInt(pow(other, self.x, MOD))
        )


def main():
    N, A, B = map(int, input().split())
    total = ModInt(2) ** N - 1
    MAX = max(A, B)
    MIN = min(A, B)

    num = ModInt(1)
    for i in range(MAX):
        if i == MIN:
            total -= num
        num *= N - i
        num /= i + 1

    total -= num
    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int x;cin>>x;
    bool ok;
    int ans;
    for (int i = x;1; i++) {
        ok=1;
        for (int j = 2; j < sqrt(i) ; j++) {
            if(i%j==0){
                ok=0;
                break;
            }
        }
        if(ok){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (x, y, z) = get!(i64, i64, i64);
    println!("{}", x * y / 2);
}


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

const double EPS = 1e-8;
using P = complex<double>;
int n;
P p[300];

int main(){
  while (cin >> n, n){
    for (int i = 0; i < n; i++){
      double x, y;
      cin >> x >> y;
      p[i] = P(x, y);
    }
    vector<P> ps;
    for (int i = 0; i < n; i++){
      for (int j = 0; j < i; j++){
        if (abs(p[i] - p[j]) >= 2.0) continue;
        P v = p[j] - p[i];
        P u = v * P(0.0, 1.0);
        u *= sqrt(1.0 - abs(v) * abs(v) / 4.0) / abs(u);
        ps.push_back(p[i] + v / 2.0 + u);
        ps.push_back(p[i] + v / 2.0 - u);
      }
    }
    int res = 1;
    for (P c : ps){
      int s = 0;
      for (int i = 0; i < n; i++){
        s += abs(c - p[i]) <= 1.0 + EPS;
      }
      res = max(res, s);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 3696
N, K = gets.chomp.split().map(&:to_i)

win_prob = 0.0
for point in 1..N do
  if point >= K
    win_prob += 1.0 / N
    next
  end
  
  t = 1
  while point * 2 ** t < K
    t += 1
  end
  
  win_prob += (1.0 / N) * (1.0 / (2 ** t))
end

puts win_prob


Measured memory_bytes: 14260
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int n;
int m;
int mem[N];
vector < int > adj[N];

int go(int u){
    if(~mem[u])
        return mem[u];
    int best = 0;
    for(auto v : adj[u]){
        best = max(best , 1 + go(v));
    }
    return mem[u] = best;
}

int main(){
    scanf("%d%d" , &n , &m);
    for(int i = 1; i <= m; i++){
        int u , v;
        scanf("%d%d" , &u , &v);
        adj[u].push_back(v);
    }
    memset(mem , -1 , sizeof mem);
    int best = 0;
    for(int i = 1; i <= n; i++){
        best = max(best , go(i));
    }
    printf("%d\n" , best);

}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, N);

  vector<i64> a(N + 10);
  reps(i, 1, N) {
    IN(a[i]);
  }

  i64 v1 = 0, v2 = 0;
  vector<i64> cum(N + 10);
  vector<i64> cum2(N + 10);
  reps(i, 1, N) {

    cum[i] = cum[i-1] + a[i];
    cum2[i] = cum2[i-1] + a[i];

    if (i % 2) {
      if (cum[i] <= 0) {
        v1 += abs(1 - cum[i]);
        cum[i] = 1;
      }
      if (cum2[i] >= 0) {
        v2 += abs(-1 - cum2[i]);
        cum2[i] = -1;
      }
    }

    else {
      if (cum[i] >= 0) {
        v1 += abs(-1 - cum[i]);
        cum[i] = -1;
      }
      if (cum2[i] <= 0) {
        v2 += abs(1 - cum2[i]);
        cum2[i] = 1;
      }
    }
  }

  OUTL(min(v1, v2));

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define llu unsigned long long 
#define ll long long 
ll read() { ll  x; if (scanf("%lld", &x) == -1)exit(0); return x; }
#define vi vector<int>
#define vb vector<bool>
const long long INF = 5e18;

#define LOCAL_JUDGE
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}


int main() {
    //c_p_c();
    int n = read();
    n = n % 10;
    set<int> s1 = { 2, 4, 5, 7, 9 };
    set<int> s2 = { 0,1,6,8 };
    set<int> s3 = { 3 };

    if (s1.find(n) != s1.end())
        cout << "hon" << endl;
    else if (s2.find(n) != s2.end())
        cout << "pon" << endl;
    else cout << "bon" << endl;

    return 0;
}



Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m,r,s=0,i,sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        m=s;
        cin>>s;
        if(i>0 && s<m){
            sum+=m-s;
            s=m;}
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3592
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#include <assert.h>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
using namespace std;

int main()
{  
    int n,cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    { 
        for (int j = 1; i*j < n ; ++j)
        {
            if( (n - i*j) > 0)
                cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	int a[3][3];
	bool check[3][3];
	int n;
	rep(i,3) rep(j,3) {
		cin >> a[i][j];
		check[i][j] = false;
	}
	cin >> n;
	vector<int> b(n);
	rep(i,n) {
		cin >> b[i];
		rep(j,3) rep(k,3) {
			if(b[i] == a[j][k]) check[j][k] = true;
		}
	}
	bool flag = false;
	rep(i,3) {
		rep(j,3) {
			if (check[i][j] == false) break;
			if (j == 2) flag = true;
		}
	}
	rep(i,3) {
		rep(j,3) {
			if (check[j][i] == false) break;
			if (j == 2) flag = true;
		}
	}
	rep(i,3) {
		if (check[i][i] == false) break;
		if (i == 2) flag = true;
	}
	rep(i,3) {
		if (check[i][2-i] == false) break;
		if (i == 2) flag = true;
	}

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long int;
int main(void){
   int K;
   cin >> K;
   vector<ll> vec;
   for(int m=1;m<10;m++)vec.push_back(m);
   int m=0;
   while(vec.size()<K){
       ll ans=vec[m];
       if(ans%10==0){
           vec.push_back(ans*10);
           vec.push_back(ans*10+1);
        }else if(ans%10==9){
            vec.push_back(ans*10+8);
            vec.push_back(ans*10+9);
        }else{
            for(int i=-1;i<=1;i++){
                vec.push_back(ans*10+ans%10+i);
            }
        }
       m++;
   }
   printf("%lld",vec[K-1]);
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define int long long
#define W 100011
#define N 111

using namespace std;
const int NEG_INF = -(int)1e15;

int n, w, v[N], we[N], opt[N][W];

int solve(int idx, int cur_w) {
	if(cur_w > w) return NEG_INF;
	if(idx+1 == 0) return 0;
	if(opt[idx][cur_w] != -1) return opt[idx][cur_w];
	opt[idx][cur_w] = max(solve(idx-1, cur_w + we[idx]) + v[idx], solve(idx-1, cur_w));
	return opt[idx][cur_w];
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> w;
	for(int i=0; i<n; i++) {
		cin >> we[i] >> v[i];
		for(int j=0; j<=w; j++) {
			opt[i][j] = -1;
		}
	}
	cout << solve(n-1,0) << endl;
	return 0;
}


Measured memory_bytes: 80128
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    def COMinit(n,MOD):
        fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
    
    fac,finv,inv=COMinit(N,MOD)
    
    def COM(n, k, MOD=MOD):
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    
    print(fac[N])

if __name__ == '__main__':
    main()


Measured memory_bytes: 40944
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, A, B;
    cin >> N;
    if (N == 1)
    {
        cout << "Hello World" << endl;
    }
    else if (N == 2)
    {
        cin >> A >> B;
        cout << A + B << endl;
    }
}


Measured memory_bytes: 256
string = input()
ch = string[0]
max_string_len = 0
prev_len = 0
for idx,ch in enumerate(string):
  if ch  in {"A","T","G","C"}:
    prev_len += 1
    max_string_len = max(max_string_len,prev_len)
  else:
    prev_len = 0
    
print(max_string_len)


Measured memory_bytes: 2940
import sys
from collections import Counter


def input():
    return sys.stdin.readline().strip()


N = int(input())
A = list(map(int, input().split()))
cntr = Counter(A)
Q = int(input())
curr_sum = sum(A)
for _ in range(Q):
    B, C = map(int, input().split())
    if B in cntr:
        curr_sum += (C - B) * cntr[B]
        cntr[C] += cntr[B]
        del cntr[B]
    print(curr_sum)


Measured memory_bytes: 21140
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BGreedyTakahashi {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        lint A, B, K;
        in>>A>>B>>K;
        if(K<A) out<<A-K<<' '<<B<<'\n';
        else if(K<A+B) out<<0<<' '<<B-K+A<<'\n';
        else out<<0<<' '<<0<<'\n';
    }
};


int main() {
	BGreedyTakahashi solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256