akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) = IO().exec {
    val n = int()
    val a = IntArray(n){int()}
    println(if (solve(n, a)) "Yes" else "No")
}

fun solve(n: Int, a: IntArray): Boolean {
    val maxA = a.max()!!
    val minA = a.min()!!
    if (maxA - minA >= 2) return false
    return if (maxA - minA == 0) {
        minA == n-1 || 2*minA <= n
    } else {
        val x = a.count { it == maxA-1 }
        val y = n - x
        x < maxA && 2*(maxA - x) <= y
    }
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 38816
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(void){
	int a,b;
	string h;
	cin >> a >> b >> h;
	b--;
	for(int i=0;i<h.size();i++){
		if(b-i)printf("%c",h[i]);
		else	printf("%c",h[i]+'a'-'A');
	}
	puts("");
	return 0;
}

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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using namespace std;
using Mint = Modint<long long, 1000000007>;

Int n, a[212345], cnt[212345];
Int sum;

int main(){
	cin >> n;
	RC(i, n){
		cin >> a[i];
		--a[i];
		++cnt[a[i]];
	}
	RC(i, n){
		sum += cnt[i] * (cnt[i] - 1) / 2;
	}
	RC(i, n){
		Int ans = sum;
		Int tmp = cnt[a[i]];
		ans -= tmp * (tmp - 1) / 2;
		ans += (tmp - 1) * (tmp - 2) / 2;
		cout << ans << endl;
	}
}


Measured memory_bytes: 4736
#include <stdio.h>

int main(void)
{
  int count_p=0, count_g=0;
  char c;

  while (1) {
    scanf("%c", &c);
    if (c == 'p')count_p++;
    else if(c=='g') count_g++;
    else break;
  }
  printf("%d\n", (count_g + count_p) / 2 - count_p);

  return(0);
}

Measured memory_bytes: 128
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  string s;
  cin >>s;
  deque<char> dq(s.size());
  for(int i=0;i<s.size();i++){
    dq[i]=s[i];
  }//文字列を配列に入れる
  int n;
  cin >>n;
  int key=0;
  for(int i=0;i<n;i++){
    int a;
    cin >>a;
    if(a==1){
      key++;//keyが偶数ならそのまま奇数なら左右反転
    }else if (a==2){//2ならさらに2つ入力
      int b;
      cin >>b;
      char c;
      cin  >>c;
      if(b==1){
        if(key%2==0){
        dq.push_front(c);
        }else{
          dq.push_back(c);
        } //dq.push_front(c)
      }else if(b==2){
        if(key%2==0){
        dq.push_back(c);
        }else{
          dq.push_front(c);
        }
       }//dq.push_back(c)
      }
    }
  if(key%2==1){
    for(int i=0;i<dq.size()/2;i++){
      swap(dq[i],dq[dq.size()-1-i]);
                    }
  }
  for(int i=0;i<dq.size();i++){
    if(i==dq.size()-1){
      cout <<dq[i]<<endl;
    }else{
      cout <<dq[i];
    }
  }
}

Measured memory_bytes: 896
#include <stdio.h>
#include<iostream>
using namespace std;
int main()
{
   double a, r, s;
   cin >> a;
   r = a * a * 3.141592653589;
   s = 2 * a*3.141592653589;
   printf("%.6f %.6f\n", r, s);
   return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int N[] = new int[50];
		int a = 0;
		int b = 0;
		int c = 0;
		N[0] = 1;
		N[1] = 1;

		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		for (int j = 2; j <= 44; j++) {
			b = N[j - 1];
			c = N[j - 2];
			a = b + c;
			N[j] = a;
		}
		System.out.println(N[n]);
	}
}


Measured memory_bytes: 26148
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    odds = [i for i in range(1, 201) if i % 2 == 1]
    ans = 0

    for j in range(1, n + 1):
        count = 0

        for odd in odds:
            if j % odd == 0:
                count += 1

        if count == 8:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] roads = new int[n];
		Arrays.fill(roads, 0);
		for(int i=0;i<m;i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			roads[a-1] ++;
			roads[b-1] ++;
		}
		for(int i=0;i<n;i++) System.out.println(roads[i]);
	}

}

Measured memory_bytes: 21716
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)

int N, M;
int P[100000], Y[100000];
vector<int> yd[100001];

int main(){

    cin >> N >> M;
    rep(i, M) cin >> P[i] >> Y[i], yd[P[i]].push_back(Y[i]);
    rep(i, N) sort(yd[i+1].begin(), yd[i+1].end());
    //rep(i, M) cout << ll(P[i]) * 1000000 + int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1 << endl;
    rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]].begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
    return 0;
}

Measured memory_bytes: 7808
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int K=sc.nextInt();
		
		String S=sc.next();
		
		if(S.length()<=K) {
			p(S);
		}else {
			StringBuffer str = new StringBuffer(S);
			str.delete(K, str.length());
			p(str.toString()+"...");
			
		}
		
		
		
		
		
		
		
	}
		
		
		
		
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 38612
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::min;
fn main() {
    input!{
        n: usize,
        a: [i64; n + 1],
        b: [i64; n],
    }
    let mut f1 = min(a[0], b[0]);
    let mut f2 = min(a[1], b[0] - f1);
    let mut ans = f1 + f2;
    for i in 1..n {
        f1 = min(a[i] - f2, b[i]);
        f2 = min(a[i + 1], b[i] - f1);
        ans += f1 + f2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 10232
#include <stdio.h>

int nDigits( int );

int main( void ) {
	int a, b;

	while ( scanf( "%d %d", &a, &b ) == 2 )
		printf( "%d\n", nDigits( a + b ) );

	return 0;
}

int nDigits( int x ) {
	int d = 1;

	while ( x /= 10 )
		d++;

	return d;
}

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

#define mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;

lld power(lld x, lld y)
{
    lld res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

lld nCrModp(lld n, lld r, lld p)
{
    if (r > n - r)
        r = n - r;
    lld C[r + 1]={0};
    C[0] = 1;

    for (lld i = 1; i <= n; i++)
    {
      for (lld j = min(i, r); j > 0; j--)
      {
        C[j] = (C[j] + C[j - 1]) % p;

      }
    }
    return C[r];
}
lld a[10][10];
lld row_cnt[10]={0};
lld col_cnt[10]={0};

// lld recur(lld i, lld j, lld h, lld w, lld k, lld sum)
// {
//   if(i==h || i==w)
//     return 0;
//   lld cnt = 0;
//   if(sum==k)
//   {
//     cnt++;
//   }
//   cnt += recur()
// }


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lld h,w,k;
  cin>>h>>w>>k;
  lld i,j;
  char ch;

  for(i=0;i<h;i++)
    for(j=0;j<w;j++)
    {
      cin>>ch;
      if(ch=='.')
        a[i][j] = 0;
      else
        a[i][j] = 1;

    }

  lld sum = 0;
  lld cnt = 0;
  for(i=0;i<h;i++)
  {
    for(j=0;j<w;j++)
    {
      if(a[i][j]==1)
      {
        row_cnt[i]++;
        sum++;
        col_cnt[j]++;
      }
    }
  }

  if(sum<k)
  {
    cout<<0<<endl;
    exit(0);
  }
  lld temp;
  for(lld msk = 0; msk < (1<<h); msk++)
  {

    for(lld msk2 = 0; msk2 <(1<<w); msk2++)
    {
      temp = 0;
      for(i=0;i<h;i++)
      {

        for(j=0;j<w;j++)
        {

          if(msk&(1<<i) && msk2&(1<<j))
          {
            if(a[i][j]==1)
              temp++;
          }
        }
      }
      if(temp==k)
        cnt++;
    }

  }
  cout<<cnt<<endl;

}


Measured memory_bytes: 3648
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  if(N % 2 == 1){
     var tmp = Math.floor(N / 2);
    myout((tmp + 1) / N);
  }else{
    myout(0.5);
  }
}

Measured memory_bytes: 7500
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<set>
#include<cmath>
#include<stack>
#include<iomanip>
#include<cstdio>
using namespace std;
int main()
{
  int x,ans=0,temp; //500->1000 5->5
  cin>>x;
  temp=x;
  ans+=(temp/500)*1000;
  if(x%500!=0)
  {
    temp-=(temp/500)*500;
    ans+=temp/5*5;
       cout<<ans<<endl;
  }
  else
    cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		while(0 < 1){
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a == 0 && b == 0) break;
			//上のフレーム
			for(int i = 0;i < b;i++) {
				System.out.printf("#");
			}
			System.out.printf("\n");
			//真ん中
			for(int j = 2;j < a;j++ ) {
				System.out.printf("#");
				for(int k = 2;k < b;k++) {
					System.out.printf(".");
				}
				System.out.printf("#\n");
			}
			//下のフレーム
			for(int i = 0;i < b;i++) {
				System.out.printf("#");
			}
			System.out.printf("\n\n");
		}
		sc.close();
	}	
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=-INF,a[101][11],b[101][11],c,d,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      rep(i,n){
        rep(j,10){
          cin>>a[i][j];
        }
      }
      rep(i,n){
        rep(j,11){
          cin>>b[i][j];
        }
      }
      for(int bit=0;bit<(1<<(10));bit++){
        ll cmp[15],cmpp[115],obara=0;
        rep(i,11)cmp[i]=0;
        rep(i,102)cmpp[i]=0;
        rep(i,10){
          if(bit & (1<<i)){
            cmp[i]=1;
            obara++;
          }
        }
        if(obara==0)continue;
        rep(i,n){
          rep(j,10){
            if(cmp[j]==1&&a[i][j]==1)cmpp[i]++;
          }
        }
        rep(i,n){
          cnt+=b[i][cmpp[i]];
        }
        ans=max(ans,cnt);
        cnt=0;
      }
      Cout(ans);
     

       
return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,M;
int X[100000];
priority_queue<int> dis; 

int main(){
    cin>>N>>M;
    rep(i,M) cin>>X[i];
    if(N>=M){
        cout<<0<<endl;
        return 0;
    }

    sort(X,X+M);

    int ans=X[M-1]-X[0];
    rep(i,M-1){
        dis.push(X[i+1]-X[i]);
    }
    rep(i,N-1){
        ans-=dis.top();
        dis.pop();
    }

    cout<<ans<<endl;
}

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

const ll siz = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll MAXX = 1e17;
const ll base = 31;

int n, a;
int ar[5][5];
int f[5][5];
int check1, check2, check3, check4, check5, check6, check7, check8;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN.INP", "r", stdin);
//    freopen ("OUT.OUT", "w", stdout);
    for (int i = 1; i <= 3; i++)
        for (int j = 1; j <= 3; j++)
            cin >> ar[i][j];
    cin >> n;
    while (n--)
    {
        cin >> a;
        for (int i = 1; i <= 3; i++)
            for (int j = 1; j <= 3; j++)
                if (ar[i][j] == a)
                {
                    f[i][j] = 1;
                    break;
                }
        check1 = 0;
        check2 = 0;
        check3 = 0;
        check4 = 0;
        check5 = 0;
        check6 = 0;
        check7 = 0;
        check8 = 0;
        for (int i = 1; i <= 3; i++)
        {
            check1 += f[1][i];
            check2 += f[2][i];
            check3 += f[3][i];
            check4 += f[i][1];
            check5 += f[i][2];
            check6 += f[i][3];
            check7 += f[i][i];
            check8 += f[i][4 - i];
            if (check1 == 3 || check2 == 3 || check3 == 3 || check4 == 3 || check5 == 3 || check6 == 3 || check7 == 3 || check8 == 3)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
Bz = [int(i) for i in input().split()]

cnt = 0
for _ in range(N):
    ans = 0
    Az = [int(i) for i in input().split()]
    for idx in range(M):
        ans += Az[idx] * Bz[idx]
    if ans + C > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
P,S=print,sorted
n,k,*t=map(int,open(i:=0).read().split())
l=S([a<1<exit(P(-1)),a-1,i:=i+1]for a in t)[::-1]
*_,r=zip(*l)
b=r
while k:
 for t in S(l)[::-1]:
  if t[2]-b[-1]:t[1]or exit(P(-1));t[1]-=1;r+=t[2],
 b=r;k-=1
P(len(r),*r)

Measured memory_bytes: 9348
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef pair<string, string> P;

int main(){
    int N;
    cin >> N;
    map<P, long> ml, mr;
    string s;
    cin >> s;
    string sl(&s[0], &s[N]);
    string sr(&s[N], &s[2*N]);
    reverse(sr.begin(), sr.end());
    for(int i = 0; i < (1<<N); i++){
       string slb, slr, srb, srr;
       for(int j = 0; j < N; j++ ){
           if((1<<j)&i){
               slr += sl[j];
               srr += sr[j];
           }else{
               slb += sl[j];
               srb += sr[j];
           }
       }
       P pl = P(slr, slb);
       if(ml.find(pl) == ml.end()){
           ml[pl] = 1;
       }else{
           ml[pl]++;
       }
       P pr = P(srr, srb);
       if(mr.find(pr) == mr.end()){
           mr[pr] = 1;
       }else{
           mr[pr]++;
       }
    }
    long ans = 0;
    for(auto iter:ml){
        //cout << iter.first.first << ' ' << iter.first.second << ' ' << iter.second << endl;
        if(mr.find(iter.first) != mr.end()){
            long add = mr[iter.first]*iter.second;
            ans += add;
            //cout << add << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 91904
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
#include<utility>
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    vector<ll> x(n);
    ll m = 100000000;
    for(ll i=0;i<n;i++) cin >> x[i];
    for(ll i=1;i<=100;i++){
        ll sum = 0;
        for(ll j=0;j<n;j++){
            sum+=((x[j]-i)*(x[j]-i));
        }
        if(sum<m){
            m = sum;
        }
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int i,n,cnt,ans;
    string s;
    cin >> n;
    ans=n;
    cnt=0;
    cin >> s;
    for(i=0;i<n-1;i++){
        if(s[i]==s[i+1]) cnt++;
        else{
            ans-=cnt;
            cnt=0;
        }
    }
    ans-=cnt;
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
from collections import deque
N=int(input())
A=list(map(int,input().split()))
D=deque(A)
m=sum(A)//2
for n in range(N//2):m-=A[2*n+1]
ans=str(2*m)
for _ in range(N-1):
    a=deque.popleft(D)-m
    ans+=" "+str(a*2)
    m=a
print(ans)

Measured memory_bytes: 14408
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define FOR(i,n) for(int i=0;i<(int)n;i++)
#define FORI(i,k,n) for(int i=k;i<(int)n;i++)
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/

int main()
{
	int n;
	while (cin >> n&&n)
	{
		vector< pii > v[10000];
		bool ch[10000] = {};
		int m; cin >> m;
		FOR(i, m)
		{
			int a, b, d;
			scanf("%d,%d,%d", &a, &b, &d);
			v[a].push_back(pii(d, b));
			v[b].push_back(pii(d, a));
		}
		ch[0] = true;
		priority_queue<pii,vector<pii>, greater<pii> > que;
		FOR(i, v[0].size())
		{
			que.push(v[0][i]);
		}
		int ans = 0;
		while (!que.empty())
		{
			pii now = que.top(); 
			que.pop();
			if (ch[now.second])continue;
			ch[now.second] = true;
			ans += now.first / 100 - 1;
			FOR(i, v[now.second].size())
			{
				que.push(v[now.second][i]);
			}
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n, a, b;
llint dp[5005][5005][2];
llint dp2[5005][2];
llint num[5005];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> a >> b;
	if(a > b) swap(a, b);
	
	dp[0][0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k < 2; k++){
				for(int l = 0; l < 2; l++){
					llint nj = j+1;
					if(k != l) nj = 1;
					if(k == 1 && l == 0 && j < a) continue;
					if(k == 0 && nj >= b) continue;
					dp[i+1][nj][l] += dp[i][j][k], dp[i+1][nj][l] %= mod;
				}
			}
		}
	}
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k < 2; k++){
				if(k == 1 && j < a) continue;
				num[i] += dp[i][j][k], num[i] %= mod;
			}
		}
	}
	
	dp2[0][0] = dp2[0][1] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 2; j++){
			if(j == 1){
				for(int k = 1; k < a; k++){
					if(i+k > n) break;
					dp2[i+k][1-j] += dp2[i][j];
					dp2[i+k][1-j] %= mod;
				}
			}
			else{
				for(int k = 1; k < b; k++){
					if(i+k > n) break;
					llint len = k;
					if(i+k < n) len--;
					if(i > 0) len--;
					len = max(len, 0LL);
					
					dp2[i+k][1-j] += dp2[i][j] * num[len] % mod;
					dp2[i+k][1-j] %= mod;
				}
			}
		}
	}
	llint ans = dp2[n][0] + dp2[n][1]; ans %= mod;
	ans = modpow(2, n) - ans + mod, ans %= mod;
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 394656
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef unsigned long long ll;
typedef pair<ll, ll> P;


int main(){
    ll h, w;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }
    
    ll res = ((h+1LL)/2LL) * ((w+1LL) / 2LL);
    res += (h/2LL) * (w/2LL);

    cout << res << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
const ll INF=1e10+1;
using namespace std;
#define NOT_EXIST -1

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

int main(){
	ll r,d,x;
	cin >> r >> d >> x;
	for(int i=0;i<10;i++){
		x = r*x - d;
		cout << x << endl;
	}
}

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

using namespace std;
const int INF = 1000000000;

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int T;
		cin >> T;
		if(T == 0){ break; }
		vector<int> t(T);
		for(int i = 0; i < T; ++i){ cin >> t[i]; }
		int N;
		cin >> N;
		const int M = 100;
		vector<int> req(M, 24);
		for(int i = 0; i < N; ++i){
			int d, m;
			cin >> d >> m;
			--d;
			req[d] = min(req[d], m);
		}
		vector< vector<int> > dp(M, vector<int>(T, INF));
		dp[0][0] = 0;
		for(int i = 0; i + 1 < M; ++i){
			for(int j = 0; j < T; ++j){
				if(dp[i][j] >= INF){ continue; }
				dp[i + 1][0] = min(dp[i + 1][0], dp[i][j] + 1);
				const int next = (j + 1) % T;
				if(t[next] > req[i + 1]){ continue; }
				dp[i + 1][next] = min(dp[i + 1][next], dp[i][j]);
			}
		}
		int answer = INF;
		for(int i = 0; i < T; ++i){
			answer = min(answer, dp[M - 1][i]);
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
import math
N = int(input())
ans = [0]*(N+1)
Nruto = math.sqrt(N)
Nruto = math.floor(Nruto)+1
for x in range(1, Nruto):
    for y in range(1, Nruto):
        for z in range(1, Nruto):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n <= N:
                ans[n] += 1
for i in range(1, N+1):
    print(ans[i])


Measured memory_bytes: 9184
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>
 
template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;
 
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
 
#define F first
#define S second
 
#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )
 
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
 
#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )
 
constexpr ll MOD = 1000000007LL;
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};
 
template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}
 
/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];
 
template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}
 
template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


int main()
{
	int N;
	cin >> N;

	vector<ll> v( N );
	rep( i, N )
	{
		cin >> v[i];
	}

	ll result = 0;
	ll tmp = 0;
	int right = 0;
	rep( left, N )
	{
		for ( ; ( ( tmp ^ v[right] ) == ( tmp + v[right] ) ) && ( right < N ); right++ )
		{
			tmp ^= v[right];
		}

		result += right - left;
		if ( left == right )
		{
			++right;
		}
		else
		{
			tmp ^= v[left];
		}
	}

	cout << result << endl;

	return ( 0 );
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<numeric>
#include<queue>
#include<string>
#include<sstream>

using namespace std;

int main(void) {

  int n;
  while(cin >> n){
    if( n == 0 ) break;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int diff = 10000000;
    for(int i=1; i<n; i++){
      diff = min(diff, a[i]-a[i-1]);
    }
    cout << diff << endl;
  }



  return 0;
}










//

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


int main() {

    ll a, b;
    int k;
    cin >> a >> b >> k;
    for (int i = a; i <= b; ++i) {
        if (i < a + k || i > b - k) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const int big=1e9+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
int main(void){
	//tourist vs Petr dream match
	int rp[6],bp[6];
	int i,j;
	lldo Rpetr=0.5,nwari=0.4;
	for(i=0;i<6;i++){cin>>rp[i];}
	for(i=0;i<6;i++){cin>>bp[i];}
	for(int h=0;h<1000;h++){
		lldo gen=0;
		for(i=0;i<6;i++){
			if(Rpetr*rp[i]>(1-Rpetr)*bp[i]){gen+=bp[i];}
			else{gen-=rp[i];}
		}
		if(gen>0){Rpetr-=nwari;}else{Rpetr+=nwari;}
		if(Rpetr>1.0){Rpetr=1.0;}
		if(Rpetr<0.0){Rpetr=0.0;}
		nwari*=0.6;
	}
	//cout<<Rpetr<<endl;
	lldo ans=0;
	for(i=0;i<6;i++){
		ans+=max(Rpetr*rp[i],(1-Rpetr)*bp[i]);
	}
	cout<< setprecision(20)<<ans/100.0<<endl;
}

Measured memory_bytes: 256
O=input()
E=input()
o=len(O)
e=len(E)

P=O[0]+E[0]
i = 1
if o > e:
	while i < o-1:
		P+=O[i]+E[i]
		i+=1
	P=P+O[o-1]
	print(P)
else:
	while i < e-1:
		P+=O[i]+E[i]
		i+=1
	P=P+O[e-1]+E[e-1]
	print(P)

Measured memory_bytes: 3064
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


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


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    S = input()

    if S <= '2019/04/30':
        print('Heisei')
    else:
        print('TBD')


if __name__ == '__main__':
    main()


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

unsigned short task_A (const unsigned short* const radius)
{
	return (unsigned short)(3) * *radius * *radius;
}

int main (void)
{
	// variables for main process
	unsigned short r;
	int            rtvl_scanf;

	// STEP.01
	// read out the given data
	rtvl_scanf = scanf("%d", &r);

	// STEP.02
	// output the answer of this task
	printf("%d\n", task_A(&r));

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>

typedef long long ll;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////
enum Status {
    Not = 0,
    Now,
    End,
};

int dfs(int now, int par, vector<vector<int>> &ki, vector<Status> &status, vector<vector<int>> &res, int depth) {
    //std::cout << "searching now: " << now << std::endl;
    status[now] = Status::Now;
    int maxdepth = depth;
    for (auto chi : ki[now]) {
        //繋がったノードを取り出す
        if (chi == par) {
            //親に戻る
            return -1;
        }
        if (status[chi] == Status::Now) {
            //ループ検出
            return -1;
        } else if (status[chi] == Status::End) {
            //探索済み：再度探索する理由はない
            maxdepth = std::max(maxdepth, depth - res[chi][0] + res[chi][1] + 1);
        } else {
            int tmp = dfs(chi, now, ki, status, res, depth+1);
            if (tmp == -1) {
                return -1;
                
            }
            maxdepth = std::max(maxdepth, tmp);
        }
    }
    status[now] = Status::End;
    res[now] = {depth, maxdepth};
    return maxdepth;
}
//////////////////////////////////////

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    
    int N;
    std::cin >> N;
    int size = (N * (N - 1)) / 2 + 1;
    vector<vector<int>> ki;
    vector<Status> status;
    vector<vector<int>> res;
    ki.resize(size);
    status.resize(size);
    ndarray(res, size, 2);
    //試合に番号をつける：i < j, i vs j = i*(n-1) - (i*(i+1))/2 + j
    //試合xの翌日の試合をxの子とする
    //この木の最大深さが答え、ループが存在すれば不可能
    
    for (int i = 0; i < N; i++) {
        int game2 = -1;
        for (int j = 0; j < N-1; j++) {
            int a, game;
            std::cin >> a;
            a -= 1;
            if (i < a) {
                game = i * (N - 1) - (i * (i + 1)) / 2 + a;
            } else {
                game = a * (N - 1) - (a * (a + 1)) / 2 + i;
            }
            if (game2 != -1) {
                ki[game2].push_back(game);
            }
            game2 = game;
        }
    }
    for (int g = 1; g <= (N*(N-1))/2; g++) {
        ki[0].push_back(g);
    }
    
    int ans = dfs(0, 0, ki, status, res, 0);
    
    std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 59120
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <stack>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto

using namespace std;
template<typename  T>
using s = set<T>;
template<typename T>
using  v = vector<T>;
template<typename T1, typename  T2>
using p = pair < T1, T2>;
typedef long long ll;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;


const int Max = 4e3 + 100;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
int n;

double dp[Max][Max];
double A[Max];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	dp[0][0] = 1 - A[0];
	dp[0][1] = A[0];

	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j <= i + 1; j++)
		{
			if (j > 0)
				dp[i][j] = dp[i - 1][j - 1] * A[i] + dp[i - 1][j] * (1 - A[i]);
			else
				dp[i][j] = dp[i - 1][j] * (1 - A[i]);
		}
	}
	double res = 0;
	for (int i = n / 2 + 1; i <= n; i++)
	{
		res += dp[n - 1][i];
	}

	cout << setprecision(10) << res;
}


Measured memory_bytes: 94720
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  vector<P> v[n];
  rep(i,n) {
    ll m;
    R m;
    rep(j,m) {
      int x,y;
      cin >> x >> y;
      x--;
      v[i].pb(P(x,y));
    }
  }
  int ans=0;
  rep(t,1<<n) {
    rep(i,n) {
      if(!(t&(1<<i))) continue;
      rep(j,v[i].size()) {
        int x=v[i][j].S,y=v[i][j].F;
        int r=t&(1<<y);
        if(r) r=1;
        if(r!=x) goto next;
      }
    }
    ans=max(ans,__builtin_popcount(t));
  next:;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
  char tmp = 'A', r;
  string a, b, c;
  cin >> a >> b >> c;
while(a.size() >= 0 && b.size() >= 0 && c.size() >= 0){
    if(tmp == 'A'){
      if(a.size() == 0){
        r = 'A';
        break;
      }
      tmp = a[0] + 'A' - 'a';
      a.erase(0, 1);
    }
    else if(tmp == 'B'){
      if(b.size() == 0){
        r = 'B';
        break;
      }
      tmp = b[0] + 'A' - 'a';
      b.erase(0, 1);
    }
    else if(tmp == 'C'){
      if(c.size() == 0){
        r = 'C';
        break;
      }
      tmp = c[0] + 'A' - 'a';
      c.erase(0, 1);
    }
  }
  cout << r << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  string str;
  cin >> str;
  int n, ans = 1e5;
  REP(i,(int) str.size()-2){
    n = 0;
    REP(j,3) n = 10*n + (str[i+j]-'0');
    ans = min(ans,abs(n-753));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let r:usize;
    input!(r);
    p(r*r);
}


Measured memory_bytes: 4352