akhauriyash/Code-Regression huggingface dataset:
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    n = int(input().strip())

    a=1;b=n
    for i in range(1, int(n**.5)+1):
        if n%i==0:
            a=i
            b=n//a
    # eprint("a,b ",end=": ")
    # eprint(a,b)
    print(a+b-2)
        
    return

if __name__ == '__main__':
    main()



    '''
    for given N (2<=N<=10**12)
    find a_cnt such that           //  := (i_ans - i) + (j_ans - j)

    
    let T such that { (i,j) | (i,j \in [1...10**12] ) and (i*j == N) }
    

    let (i_ans, j_ans) \in T such that

    ( (i_ans, j_ans) \in T )
    and
    ( for all (i,j) \in T . (i_ans - 1) + (j_ans - 1) <= (i-1)+(j-1) )

    find a_cnt := (i_ans - 1) + (j_ans - 1)


    //
    [1, 1] -> [i_ans, j_ans] such that ( i_ans * j_ans = N )
    
    
    (1 <= i_ans <= , 1 <= j_ans <= )
    
    
    
    
    
    
    '''


Measured memory_bytes: 38512
#[allow(unused_imports)]
use std::io;

#[allow(unused_macros)]
macro_rules! get {
    ($i:ident) => {
        let mut $i = String::new();
        io::stdin().read_line(&mut $i).ok();
    };
}

#[allow(unused_macros)]
macro_rules! to_vec {
    ($s:ident, $t:ty) => {
        $s.split_whitespace().map(|i| i.parse().ok().unwrap()).collect::<Vec<$t>>()
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($s:ident, $t:ty) => {
        $s.trim().parse::<$t>().ok().unwrap()
    }
}

#[allow(unused_macros)]
macro_rules! max {
    ($v:ident) => {
        $v.iter().max().unwrap()
    };
}

#[allow(unused_mut)]
fn main() {
    get!(s);
    let mut v = to_vec!(s, i32);
    let k = v[0];
    let x = v[1];
    let mut r: Vec<i32> = Vec::new();
    r.append(&mut ((x-(k-1))..(x+k)).collect::<Vec<i32>>());
    for i in r.iter() {
        print!("{} ", i);
    }
}

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

int main() {
  int n;
  cin >> n;
  long long l[n];
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (l[i]==l[j]||l[j]==l[k]||l[i]==l[k]) continue;
        else {
          if (l[i]+l[j]>l[k] && l[k]+l[j]>l[i] && l[i]+l[k]>l[j]) cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3588
L = input()

mod = 10 ** 9 + 7
n = len(L)
dp1 = 2
dp2 = 1

for i in range(1, n):
    if L[i] == "0":
        dp2 = (3 * dp2) % mod
    else:
        dp2 = (3 * dp2 + dp1) % mod
        dp1 = (2 * dp1) % mod

print((dp1 + dp2) % mod)


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

int main(){
    int A,B,C,X,Y,m,l,s, res=1e9;

    cin >> A >> B >> C >> X >> Y;

    m = A*X + B*Y;
    res = min(m,res);
    l = max(X,Y);
    s = min(X,Y);
    for (int i=0;i<s;i++){
        m = m + 2*C - A - B;
        res = min(m,res);
    }
    if (X >= Y){
        res = min (res,m+(2*C-A)*(l-s));
    }
    else{
        res = min (res,m+(2*C-B)*(l-s));
    }
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

    cout << res << endl;
}


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

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> h(n+1);//index=展望台i,value=標高
  set<int> s;
  for(int i = 1; i <= n; i++) {
    cin >> h[i];
    s.insert(i);
  }
  for(int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if(h[a] == h[b]) {
      s.erase(a);
      s.erase(b);
    }
    else if(h[a] > h[b]) s.erase(b);
    else s.erase(a);
  }
  cout << s.size();
}

Measured memory_bytes: 8372
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

x = itertools.permutations(list(range(1, n+1)), n)
pnum = 0
qnum = 0
for index, xx in enumerate(x):
  if(list(xx) == p):
    pnum = index
  if(list(xx) == q):
    qnum = index
    
print(abs(pnum - qnum))


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<array>
using namespace std;

int main(){
    array<int, 3> x;
    int max = 0;
    int sum = 0;

    //cin >> a >> b >> c;
    for(int i = 0; i < 3; i++){
        cin >> x[i];
        if(x[max] <= x[i]){
            max = i;
        }
        //cout << max << endl;
    }

    switch(max){
        case 0: sum = x[1] + x[2]; break;
        case 1: sum = x[0] + x[2]; break;
        case 2: sum = x[0] + x[1]; break;
        default : cout << "error" << endl;
    }


    if(sum == x[max])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }



int main()
{
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        if(a[i] % 2 == 0)
        {
            while(a[i]%2 == 0)
            {
                a[i] /= 2;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(rall(a));

    ll m = n/2;
    ll ans = a[0];
    exrep(i, 1, m-1) {
        ans += 2*a[i];
    }
    if(n%2 == 1) {
        ans += a[m];
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<pair<ii,ii> > req;

int score(vi v)
{
	reverse(v.begin(),v.end());
	int ans=0;
	for(auto X:req)
	{
		if(v[X.fi.se]-v[X.fi.fi]==X.se.fi) ans+=X.se.se;
	}
	return ans;
}

int mx=0;

void solve(int n, int m, vi &vec)
{
	if(n==0)
	{
		mx=max(mx,score(vec)); return ;
	}
	for(int i=m;i>=1;i--)
	{
		vec.pb(i);
		solve(n-1,i,vec);
		vec.pop_back();
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m,q; cin>>n>>m>>q;
	for(int i=0;i<q;i++)
	{
		int a,b,c,d; cin>>a>>b>>c>>d; a--; b--;
		req.pb({{a,b},{c,d}});
	}
	vi vec = {};
	solve(n,m,vec);
	cout<<mx<<'\n';
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N;
ll h[100010];
bool low_than_left[100010] = {0};

int main() {
    cin >> N;

    // 初期化
    cin >> h[0];
    low_than_left[0] = false;
    low_than_left[N] = false;

    for (int i = 1; i < N; i++) {
        cin >> h[i];
        if (h[i-1] >= h[i]) low_than_left[i] = true;
    }

    int ans = 0, tmp = 0;
    for (int i = 1; i <= N; i++) {
        if (low_than_left[i]) tmp++;
        else {
            if (tmp > ans) ans = tmp;
            tmp = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var a = r[0].Int();
            var b = r[1].Int();
            var h = r[2].Double();
            var m = r[3].Double();

            var hk = (h + (m / 60)) * 30;
            var mk = m * 6;
            var cos = Math.Min(Math.Abs(hk - mk), Math.Abs(mk - hk));
            if (cos >= 180)
            {
                cos = Math.Abs(cos - 360);
            }
            double rad = System.Math.PI * cos / 180.0;
            var ans = a * a + b * b - 2 * a * b * Math.Cos(rad);
            WriteRead(Math.Sqrt(ans));
        }
        
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 18724
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC046__AtCoDeer_and_Paint_Cans
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');

			List<string> inputnumbers = new List<string>();
			inputnumbers.Add(input[0]);
			inputnumbers.Add(input[1]);
			inputnumbers.Add(input[2]);
			inputnumbers = inputnumbers.Distinct().ToList();

			int result = inputnumbers.Count();
			
			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 11232
#include <iostream>

using namespace std;

int main(){
    long long int n,m; cin >> n >> m;
    
    if(n == 1) n = 1;
    else n = n-2;

    if(m == 1) m = 1;
    else m = m-2;
    
    cout << m * n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

long long gcd(long long m, long long n){
    while (n > 0){
        long long r = m % n;
        m = n;
        n = r;
    }
    return m;
}

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

    int res = A[0];
    for(int i=0; i<N; i++){
        res = gcd(res, A[i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

int toint(char a,char b,char c){
	int ans=0;
	ans+=int(a-'0')*100;
	ans+=int(b-'0')*10;
	ans+=int (c-'0');
	return ans;
}

void solve(){
	int x=753;
	string s;
	cin>>s;
	int ans=1e8;
	rep(i,sz(s)-2){
		ans=min(ans,abs(toint(s[i],s[i+1],s[i+2])-x));
	}
	cout<<ans;



}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////



ll h,w;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
bool valid(ll a,ll b){
    if(0<=a&&a<=h-1&&0<=b&&b<=w-1)return true;
    return false;
}

int main(){fastio
    cin>>h>>w;
    string s[h];rep(i,0,h-1)cin>>s[i];
    ll dp[h][w];rep(i,0,h-1)rep(j,0,w-1)dp[i][j]=inf;
    queue<l_l>q;
    rep(i,0,h-1)rep(j,0,w-1){
        if(s[i][j]=='#'){
            q.push({i,j});
            dp[i][j]=0;
        }
    }
    
    while(!q.empty()){
        l_l t=q.front();q.pop();
        rep(z,0,3){
            ll nx=t.fi+dx[z];
            ll ny=t.se+dy[z];
            if(valid(nx,ny)&&chmin(dp[nx][ny],dp[t.fi][t.se]+1)){
                q.push({nx,ny});
            }
        }
    }
    
    ll ans=0;rep(i,0,h-1)rep(j,0,w-1)chmax(ans,dp[i][j]);
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 25524
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=1000005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int dp[3005][3005];
int32_t main()
{
    IOS;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int i=a;i<=c;i++)
    {
        for(int j=b;j<=d;j++)
        {
            dp[i][j]+=(dp[i-1][j]*j)%mod;
            dp[i][j]+=(dp[i][j-1]*i)%mod;
            int sub=(dp[i-1][j-1]*(i-1)*(j-1))%mod;
            dp[i][j]=(dp[i][j]-sub+mod)%mod;
        }
    }
    cout<<dp[c][d];
}

Measured memory_bytes: 73904
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;

int main(){
  int map[20][20];
  int n;
  int i,l;
  int a,b;
  int x,y;
  
  for(;;){
    cin>>a>>b;
    if(a==0&&b==0) break;
    
    memset(map,0,sizeof(map));
    cin>>n;
    for(i=0;i<n;i++){
      cin>>x>>y;
      map[y][x]=-1;
    }
    
    for(i=1;i<=b;i++){
      for(l=1;l<=a;l++){
        if(i==1&&l==1){
          map[i][l]=1;
          continue;
        }          
        
        if(map[i][l]==-1)
          map[i][l]=0;
        
        else
          map[i][l]=map[i][l-1]+map[i-1][l];
      }
    }
    
    printf("%d\n",map[b][a]);
  }
  return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {

	var s string
	var first int
	var last int
	var length int

	fmt.Scan(&s)

	// input check
	if len(s) < 1 && 200000 < len(s) {

		fmt.Println("overflow")
		os.Exit(0)
	}

	s_array := strings.Split(s, "")
	first = strings.Index(s, "A")
	last = strings.LastIndex(s, "Z")

	length = len(s_array[first : last+1])

	fmt.Println(length)

}


Measured memory_bytes: 5248
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,n) n = unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

 
/*
struct point
{
long long dist; long long name;
bool operator<(const point& rhs) const {
return dist > rhs.dist;
}
};
*/

ll const MAX = 605;
ll const MOD = 1e9 + 7;
ll dp[MAX][MAX] = {};
ll a[MAX], b[MAX];
ll ffnc[MAX];
ll unused[MAX] = {};

ll mod_p(ll x, ll y) {
	return (x + y + MOD) % MOD;
}
ll mod_m(ll x, ll y) {
	return x * y%MOD;
}
void init(ll n) {
	ffnc[0] = 1;
	ffnc[1] = 1;
	ffnc[2] = 2;
	REP(i, 3, n) {
		ffnc[i] = i * ffnc[i - 2] % MOD;
	}
}

ll ffunc(ll i) {
	if (i <= 0) return 1;
	return ffnc[i];
}

int main() {
	ll n, k;
	cin >> n >> k;
	n *= 2;
	REP(i, 1, MAX - 1) {
		unused[i] = 1;
	}
	REP(i, 1, k) {
		cin >> a[i] >> b[i];
		if (a[i] > b[i]) {
			swap(a[i], b[i]);
		}
		unused[a[i]] = unused[b[i]] = 0;
	}
	REP(i, 1, n) {
		unused[i] += unused[i - 1];
	}
	ll all_unused = unused[n];
	init(n);
	ll ans = 0;
	REP(i, 1, n) {
		for (ll j = i + 1; j <= n; j += 2) {
			bool flag = 0;
			REP(l, 1, k) {
				ll lef = a[l]; ll rig = b[l];
				if ((lef < i && i <= rig && rig <= j) || 
					(i <= lef && lef <= j && j < rig)) {
					flag = 1;
					break;
				}
			}
			if (flag) continue;
			ll p = unused[j] - unused[i - 1];
			ll v = ffunc(p - 1);
			for (ll l = i + 1; l < j; l += 2) {
				ll q = unused[j] - unused[l];
				v = mod_p(v, -mod_m(dp[i][l], ffunc(q-1)));
			}
			dp[i][j] = v;
			ans = mod_p(ans, mod_m(v, ffunc(all_unused - p - 1)));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3072
import sys
sys.setrecursionlimit(10**6)
N = int(input())
G = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)


d1 = [None] * (N+1)
dn = [None] * (N+1)


def dfs(v, d, d_list):
    d_list[v] = d
    for nv in G[v]:
        if d_list[nv] is None:
            dfs(nv, d+1, d_list)

dfs(1, 0, d1)
dfs(N, 0, dn)

cnt = 0
for i in range(1, N+1):
    if d1[i] <= dn[i]:
        cnt += 1
    else:
        cnt -= 1

print('Fennec' if cnt > 0 else 'Snuke')


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


int main() {
  ll n, l, t;
  ll p = 1;
  cin >> n >> l >> t;
  int pla[100100];
  for(int i = 1; i <= n; i++) {
    int x , w;
    cin >> x >> w;
    if(w==1) {
      pla[i] = (x+t)%l;
      p += (x+t)/l;
    }
    else {
      pla[i] = (x-t)%l;
      p += (x-t)/l;
    }
    if(pla[i]<0) {
      pla[i] += l;
      p--;
    }
  }
  sort(pla+1, pla+n+1);
  p = (p%n+n)%n;
  if(p==0) p = n;
  for(int i = p; i <= n; i++) cout << pla[i] << endl;
  for(int i = 1; i <= p-1; i++) cout << pla[i] << endl;
  return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int a[MAXN];
int main()
{
	int n;
	while(cin>>n){
		int four=0,one=0,two=0;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			if (a[i]%4==0) four++;
			else if (a[i]%2==0) two++;
			else one++;
		}
		if (one>four+1 || (one==four+1 && two!=0)) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	return 0;
}

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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector <int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }

  int mx = 0;
  int mn = 1e9 + 1;
  for(int i = 0; i < n; i++) {
    mx = max(mx, a[i]);
    mn = min(mn, a[i]);
  }
  cout << mx - mn << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _173B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine() ?? string.Empty);
            string[] ResultFormat = {"AC","WA","TLE","RE" };
            long[] ResultNumber = {0, 0, 0, 0};
            for (long i = 0; i < N; i++)
            {
                var read = Console.ReadLine();
                for (var j = 0; j < ResultFormat.Length ; j++)
                {
                    if (ResultFormat[j] == read)
                    {
                        ResultNumber[j]++;
                    }
                }
            }

            for (var j = 0; j < ResultFormat.Length; j++)
            {
                Console.WriteLine("{0} x {1}", ResultFormat[j], ResultNumber[j]);
            }


        }
    }
}


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

using namespace std;

#define rep(i,n) for(int i=0; i < int(n); i++)
#define rev_rep(i,n) for(int i=n; i > 0; i--)

int main(){
    int n,k,s;
    cin >> n;
    cin >> k;
    vector<int> d(10);
    size_t l = to_string(n).length();
    rep(i,10) d.at(i) = i;

    rep(i,k){
        cin >> s;
        d.erase(remove(d.begin(),d.end(),s),d.end());
    }
    vector<int>::iterator max = max_element(d.begin(),d.end());
    vector<int>::iterator min = min_element(d.begin(),d.end());
    vector<int>::iterator iter;
    int largest = 0,
        ans = 0,
        tmp;
    
    rep(i,l) largest += *max * pow(10,i);
    if(n > largest){
        if(*min == 0) ans += *(min+1) * pow(10,l);
        else ans += *min * pow(10,l);
        rep(i,l) ans += *min * pow(10,i);
        cout << ans << endl;
    }
    else{
        rev_rep(i,l){
            iter = max;
            while(1){
                tmp = ans + *iter * pow(10,i-1);
                rep(j,i-1) tmp += *max * pow(10,j);
                if(tmp >= n){
                    if(iter == min){
                        ans += *iter * pow(10,i-1);
                        break;
                    }
                    else iter--;
                }
                else{
                    iter++;
                    ans += *iter * pow(10,i-1);
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

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

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

    int n, ans = 0;
    cin >> n;
    pair<int, int> p[n];

    for (int i = 0; i < n; i++)
        cin >> p[i].first, p[i].second = i;

    sort(p, p + n);
    for (int i = 0; i < n; i++)
        if (i % 2 != p[i].second % 2)
            ans++;

    cout << ans / 2 << "\n";
}

Measured memory_bytes: 4372
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

typedef long long ll;
ll ans;

int main(){
	int a[3];
	while(~scanf("%d %d %d", &a[0], &a[1], &a[2])){
		sort(a, a + 3);
		if(a[0] + a[1] == a[2])  cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc054_d
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[,] dp = new int[500, 500];
			int inf = 100000000;
			for (int i = 0; i < 500; i++)
			{
				for (int j = 0; j < 500; j++) dp[i, j] = inf;
			}
			dp[0, 0] = 0;
			for (int i = 0; i < x[0]; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				for (int j = 499; j >= a[0]; j--)
				{
					for (int k = 499; k >= a[1]; k--)
					{
						dp[j, k] = Math.Min(dp[j - a[0], k - a[1]] + a[2], dp[j, k]);
					}
				}
			}
			int ret = inf;
			for (int i = 1; i < 500 / Math.Max(x[1], x[2]); i++)
			{
				ret = Math.Min(ret, dp[x[1] * i, x[2] * i]);
			}
			Console.WriteLine(ret != inf ? ret : -1);
		}
	}
}

Measured memory_bytes: 14048
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int n, m;
vector<int> p1, p2;
int main()
{
  while(cin >> n >> m && n && m){
    p1.clear();
    p2.clear();
    
    //chap1
    p1.push_back(0);
    for(int i = 0; i < n; i++){
      int p;
      cin >> p;
      p1.push_back(p);
    }

    //chap2
    for(int i = 0; i <= n; i++)
      for(int j = i; j <= n; j++)
	p2.push_back(p1[i] + p1[j]);

    sort(p2.begin(), p2.begin() + p2.size());

    //chap3
    int ans = 0;
    for(int i = 0; i < p2.size(); i++){
      vector<int>::iterator count2 = lower_bound(p2.begin(), p2.end(), m - p2[i]);
      if(count2 != p2.begin())
	ans = max(ans, *(count2 - 1) + p2[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3172
import re
class c(int):
    global p
    def __add__(self,n):
        return c((int(self)+int(n))%p)
    def __sub__(self,n):
        return c((int(self)-int(n))%p)
    def __mul__(self,n):
        return c((int(self)*int(n))%p)
    def __truediv__(self,n):
        if n==0:raise ZeroDivisionError
        return self*pow(int(n),p-2,p)
  
while 1:
    p,f=input().replace(' ','').split(':')
    p=int(p)
    if p==0:break
    try:print('%s = %s (mod %s)'%(f,eval(re.sub(r'(\d+)',r'c(\1)',f)),p))
    except:print('NG')

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


const int maxn = 1e6+5;
int main(){
    ll x; cin >> x;
    ll y = x/500*1000;
    ll z = x%500;
    ll x1 = z/5*5;
    cout << y + x1 << endl;
}


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

using namespace std;

const long long int MOD = 1e9 + 7;
long long int dp[100001][13];

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

	string s;
	int n;

	cin >> s;

	n = s.length();

	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;

	for(int i=0;i<n;i++)
	{
		if(s[i]=='?')
		{
			for(int j=0;j<10;j++)
			{
				for(int k=0;k<13;k++)
				{
					dp[i+1][(j+(10*k))%13] = ((dp[i+1][(j+(10*k))%13]%MOD) + (dp[i][k]%MOD)%MOD);
					dp[i+1][(j+(10*k))%13]%=MOD;
				}
			}
		}
		else
		{
			int x = s[i] - '0';
			for(int j=0;j<13;j++)
			{
				dp[i+1][(10*j+x)%13] = ((dp[i+1][(10*j+x)%13]%MOD) + (dp[i][j]%MOD)%MOD);
				dp[i+1][(10*j+x)%13]%=MOD;
			}
		}
	}

	cout << dp[n][5] << '\n';

	return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int N;int u,v;
vector<int> g[size];
vector<pair<int,int>> dist(size);
int d[size]={};int ans=0;
void dfs1(int p,int s){
	for(int k:g[s]){
		if(k==p) continue;
		dist[k].first=dist[s].first+1;
		dfs1(s,k);
	}return;
}
void dfs2(int p,int s){
	for(int k:g[s]){
		if(k==p) continue;
		dist[k].second=dist[s].second+1;
		dfs2(s,k);
	}return;
}
void dfs(int p,int s){
    ans=max(ans,dist[s].second);
    for(int k:g[s]){
		if(k==p) continue;
		if(dist[k].first>=dist[k].second) continue;
		dfs(s,k);
	}return;
}
int main(){
	cin>>N>>u>>v; u--; v--;
	int a,b;
	rep(i,0,N-1){
		cin>>a>>b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dist[u].first=0;dfs1(-1,u);
	dist[v].second=0;dfs2(-1,v);
    dfs(-1,u);//ans=dist[u].second;
    cout<<ans-1<<endl;
}

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  int a, p;
  cin >> a >> p;
  cout << (3 * a + p) / 2 <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int h, w, k[31][31], cnt;
long long cx[21], cy[21], y[21][21], z[21][21], bfs[31][31], a, b, c[10], sum, minx, sum2; bool s[31][31];
char p;

int main() {
	while (true) {
		memset(z, 0, sizeof(z));
		cin >> w >> h; cnt = 1; if (!w) { break; }
		for (int i = 0; i < 22; i++) { 
			for (int j = 0; j < 22; j++) { 
				k[i][j] = 1; 
			} 
		}
		cnt = 1;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				cin >> p;
				if (p != 'x') { k[i][j] = 0; }
				if (p == '*') { cx[cnt] = j; cy[cnt] = i; cnt++; }
				if (p == 'o') { cx[0] = j; cy[0] = i; }
			}
		}

		for (int i = 0; i < 10; i++) { c[i] = i; }

		for (int i = 0; i < cnt; i++) {
			//bfs.
			queue<int> Q;
			memset(bfs, 10, sizeof(bfs));memset(s, false, sizeof(s));
			bfs[cy[i]][cx[i]] = 0;

			Q.push(cy[i] * 30 + cx[i]);
			s[cy[i]][cx[i]] = true;
			while (!Q.empty()) {
				a = Q.front() / 30;
				b = Q.front() % 30;
				if (k[a - 1][b] == 0 && s[a - 1][b] == false) { 
					s[a - 1][b] = true; Q.push((a - 1) * 30 + b); bfs[a - 1][b] = bfs[a][b] + 1;
				}
				if (k[a + 1][b] == 0 && s[a + 1][b] == false) {
					s[a + 1][b] = true; Q.push((a + 1) * 30 + b); bfs[a + 1][b] = bfs[a][b] + 1;
				}
				if (k[a][b - 1] == 0 && s[a][b - 1] == false) {
					s[a][b - 1] = true; Q.push(a * 30 + b - 1); bfs[a][b - 1] = bfs[a][b] + 1;
				}
				if (k[a][b + 1] == 0 && s[a][b + 1] == false) {
					s[a][b + 1] = true; Q.push(a * 30 + b + 1); bfs[a][b + 1] = bfs[a][b] + 1;
				}
				Q.pop();
			}
			
			for (int j = 0; j < cnt; j++) {
				z[i][j] = bfs[cy[j]][cx[j]];
			}
		}
		minx = 114514;
		do
		{
			sum = z[0][c[0] + 1];
			for (int i = 0; i < cnt - 2; i++) { 
				sum += z[c[i] + 1][c[i + 1] + 1]; 
			}
			minx = min(minx, sum);
		} while (next_permutation(c, c + cnt - 1));
		if (minx == 114514) { minx = -1; }
		cout << minx << endl;
	}
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 200200;

struct edge
{
	int x, y;

	int depth;
	int any;

	edge()
	{
		x = y = -1;
		depth = 0;
		any = 0;
	}
};

vector<edge> E;
VI g[MAX];
VI I[MAX];
VI L[MAX];
VI R[MAX];
VI L2[MAX];
VI R2[MAX];
int D[MAX];
int U[MAX];
int ANY[MAX];
char S[MAX];

int dfs1(int x, int p)
{
	int res = 0;
	ANY[x] = S[x] - '0';
	FOR (i, 0, SZ(g[x]))
	{
		int e = g[x][i];
		int to = E[e].y;
		if (to == p) continue;

		E[e].depth = dfs1(to, x);
		res = max(res, E[e].depth);

		if (ANY[to])
		{
			ANY[x] = 1;
			E[e].any = true;
		}
	}
	return res + 1;
}

void dfs2(int x, int p, int ind)
{
	if (ind != -1)
	{
		int r = I[x][ind];

		int mx = 0;
		int mx2 = 0;
		if (r)
		{
			mx = max(mx, L[p][r - 1]);
			mx2 = max(mx2, L2[p][r - 1]);
		}
		if (r < SZ(g[p]) - 1)
		{
			mx = max(mx, R[p][r + 1]);
			mx2 = max(mx2, R2[p][r + 1]);
		}

		mx++;

		int e = g[x][ind];
		mx2 = max(mx2, S[E[e].y] - '0');

		E[e].depth = mx;
		E[e].any = mx2;
	}

	L[x].resize(SZ(g[x]));
	R[x].resize(SZ(g[x]));

	L2[x].resize(SZ(g[x]));
	R2[x].resize(SZ(g[x]));

	int mx = 0;
	int mx2 = 0;

	U[x] = INF;

	FOR (i, 0, SZ(g[x]))
	{
		int e = g[x][i];
		int val = E[e].depth;

		L[x][i] = R[x][i] = val;
		L2[x][i] = R2[x][i] = E[e].any;

		if (E[e].any)
		{
			U[x] = min(U[x], E[e].depth);
		}

		if (val > mx)
		{
			mx2 = mx;
			mx = val;
		}
		else
		{
			if (val > mx2)
			{
				mx2 = val;
			}
		}
	}

	D[x] = min(mx - 1, mx2 + 1);

	FOR (i, 1, SZ(g[x]))
	{
		L[x][i] = max(L[x][i], L[x][i-1]);
		L2[x][i] = max(L2[x][i], L2[x][i-1]);
	}

	RFOR(i, SZ(g[x]) - 1, 0)
	{
		R[x][i] = max(R[x][i], R[x][i+1]);
		R2[x][i] = max(R2[x][i], R2[x][i+1]);
	}



	FOR (i,0 , SZ(g[x]))
	{
		int e = g[x][i];
		int to = E[e].y;

		if (to == p) continue;
		dfs2(to, x, I[x][i]);
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	FOR (i, 0, n-1)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;

		I[x].PB(SZ(g[y]));
		I[y].PB(SZ(g[x]));

		edge e;
		e.x = x; e.y = y;
		g[x].PB(SZ(E));
		E.PB(e);

		e.x = y; e.y = x;
		g[y].PB(SZ(E));
		E.PB(e);
	}

	scanf("%s", S);

	dfs1(0, -1);
	dfs2(0, -1, -1);

	LL res = 0;
	FOR (i, 0, n)
	{
		if (S[i] == '1') res += D[i] + 1;
		else
		{
			if (U[i] <= D[i])
			{
				res += D[i] - U[i] + 1;
			}
		}
	}
	res++;
	cout<<res<<endl;

	/*FOR (i, 0, n)
	{
		cout<<i<<' '<<D[i]<<' '<<U[i]<<endl;
	}
	cout<<endl;

	FOR (i, 0, SZ(E))
	{
		cout<<E[i].x<<' '<<E[i].y<<' '<<E[i].depth<<' '<<E[i].any<<endl;
	}*/



}


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

int main(){
 int A, B;
 string S;
 
  cin >> A >> B;
  cout << endl;
  cin >> S;
  
  if( S[A] != '-' ) { cout << "No" << endl; return 0; }
  for(int i = 0; i < A + B; i++){
   if( i == (A) ) { continue; }
    if( S[i] == '-' ) { cout << "No" << endl; return 0; }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int puzzle[10][10];
int col[10][10], row[10][10]; // 列，行
bool check[10][10];  // 間違っている場合はfalse
int n;

/*
  rect[0] rect[1] rect[2]
  rect[3] rect[4] rect[5]
  rect[6] rect[7] rect[8]
*/
int rect[10][10];

void solve()
{
    // 行・列のチェック
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            // 列のチェック
            if (col[j][puzzle[i][j] - 1] != -1) {
                int bf = col[j][puzzle[i][j] - 1];
                check[bf][j] = check[i][j] = false;
                col[j][puzzle[i][j] - 1] = i;
            }
            else
                col[j][puzzle[i][j] - 1] = i;

            // 行のチェック
            if (row[i][puzzle[i][j] - 1] != -1) {
                int bf = row[i][puzzle[i][j] - 1];
                check[i][bf] = check[i][j] = false;
                row[i][puzzle[i][j] - 1] = j;
            }
            else
                row[i][puzzle[i][j] - 1] = j;
        }
    }

    // 3x3の領域のチェック
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                int x = (i % 3) * 3 + k;
                int y = (i / 3) * 3 + j;

                if (rect[i][puzzle[y][x] - 1] != -1) {
                    int nx = (i % 3) * 3 + (rect[i][puzzle[y][x] - 1] % 3);
                    int ny = (i / 3) * 3 + (rect[i][puzzle[y][x] - 1] / 3);

                    check[ny][nx] = check[y][x] = false;
                    rect[i][puzzle[y][x] - 1] = j * 3 + k;
                }
                else
                    rect[i][puzzle[y][x] - 1] = j * 3 + k;                    
            }
        }
    }

    for (int i = 0; i < 9; i++)
        for (int j = 0; j < 9; j++) {
            if (check[i][j]) 
                printf(" %d", puzzle[i][j]);
            else
                printf("*%d", puzzle[i][j]);
            
            if (j + 1 == 9)
                putchar('\n');
        }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 9; j++)
            for (int k = 0; k < 9; k++) {
                cin >> puzzle[j][k];
                col[j][k] = row[j][k] = rect[j][k] = -1;
                check[j][k] = true;
            }

        if (i != 0)
            putchar('\n');
        solve();
    }
        

    return 0;
}

Measured memory_bytes: 1144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String boin = scan.next();
		if(boin.equals("a") || boin.equals("i") || boin.equals("u") || boin.equals("e") || boin.equals("o")){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}

	}

}


Measured memory_bytes: 21716
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

#define EPS (1e-10)

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

double sqrt2(double a) {
    double b = a;
    for(int i = 0; i < 10000; i++) {
        b = (b * b + a) / (2 * b);
    }
    return b;
}

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

    ll a, b, c; cin>>a>>b>>c;

    ll r = (c - a - b) * (c - a - b);
    ll l = 4 * a * b;

    if(c - a - b <= 0){
        cout << "No" << endl;
        return 0;
    }

    if(l < r) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;

  vll x(n), y(n);
  REP(i, n) {
    cin >> x[i] >> y[i];
  }

  vll v(n);
  iota(v.begin(), v.end(), 0);
  ll count = 0;
  ld total = 0;
  do {
    REP(i, v.size() - 1) {
      total += sqrt(pow(x[v[i]] - x[v[i + 1]], 2) + pow(y[v[i]] - y[v[i + 1]], 2));
    }
    count++;
  } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成

  COUT(total / count);


}



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

/*
2
-879 981
-866 890
*/


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

int main() {
  int a,b;
  string c;
  cin>>a>>b>>c;
  if(c.at(b-1)=='A')
    c.at(b-1)='a';
  else if(c.at(b-1)=='B')
    c.at(b-1)='b';
  else
    c.at(b-1)='c';
  cout<<c<<endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;


int h, w;
bool contain(int y, int x){
   return (0 <= y && y < h && 0 <= x && x < w);
}
int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    char c[51][51];
    rep(i, 0, h) rep(j, 0, w) cin >> c[i][j];
    rep(i, 0, h){
        rep(j, 0, w){
            if(c[i][j] == '#') continue;
            int cnt = 0;
            rep(k, 0, 8){
                int ny = i + dy[k];
                int nx = j + dx[k];
                if(!contain(ny, nx)) continue;
                if(c[ny][nx] == '#') cnt++;
            }
            c[i][j] = (char)('0' + cnt);
        }
    }
    rep(i, 0, h){
        rep(j, 0, w){
            cout << c[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
from bisect import bisect_left
ans = 0
for i in range(N):
    b = B[i]
    inda = bisect_left(A,b)
    indc = bisect_left(C,b+1)
    ans += (N-indc)*inda
print(ans)

Measured memory_bytes: 92644
// Isaunoya
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
inline int read() {
  register int x = 0 , f = 1 ;
  register char c = getchar() ;
  for( ; ! isdigit(c) ; c = getchar()) if(c == '-') f = -1 ;
  for( ; isdigit(c) ; c = getchar()) x = (x << 1) + (x << 3) + (c & 15) ;
  return x * f ;
}
template < class T > inline bool cmax(T & x , T y) {
  return x > y ? 1 : x = y , 0 ;
}
template < class T > inline bool cmin(T & x , T y) {
  return x < y ? 1 : x = y , 0 ;
}
const int mod7 = 1e9 + 7 ;
const int mod9 = 1e9 + 9 ;
const int mod = 998244353 ;
inline int QP(int x , int y , int Mod){ int ans = 1 ;
  for( ; y ; y >>= 1 , x = (x * x) % Mod)
    if(y & 1) ans = (ans * x) % Mod ;
  return ans ;
}
const int MAXN = 205 ;
int n,m;
bool a[MAXN][MAXN];
char s[MAXN][MAXN];

void rd() {
	// fucker ;
}

int dis[MAXN];
int ans = -1;

bool bfs(int s) {
//	while(!q.empty()) q.pop();
	queue < int > q ;
	memset(dis,-1,sizeof(dis));
	q.push(s);
	dis[s] = 0;
	while(!q.empty()) {
		int x = q.front();
		q.pop();
		for(register int i = 1; i <= n; i ++)
			if(a[x][i]) {
				if(dis[i] == -1) {
					dis[i] = dis[x]+1;
					q.push(i);
				} else {
					if(dis[x] == dis[i]+1 || dis[i] == dis[x]+1) ;
					else return 0;
				}
			}
	}
	for(register int i = 1; i <= n; i ++) cmax(ans , ++ dis[i]) ;
	return 1;
}

signed main() {
	n = read() ;
	for(register int i = 1; i <= n; i ++) {
		scanf("%s",s[i]+1);
		for(int j = 1; j <= n; j ++)
			a[i][j] = s[i][j]-'0';
	}
	for(register int i = 1; i <= n; i ++) bfs(i);
	printf("%lld\n" , ans) ;
	return 0;
}

Measured memory_bytes: 384