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

#define N 100000

using namespace std;

int n, m, k;

int main() {
    // freopen ("a.in", "r", stdin);
    int i, j;


    int a, b, c, d;
    char q = cin.get();
    a = q - '0';

    q = cin.get();
    b = q - '0';
    q = cin.get();
    c = q - '0';
    q = cin.get();
    d = q - '0';


    if (a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7";
    else if (a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7";
    else if (a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7";
    else if (a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7";
    else if (a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7";
    else if (a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7";
    else if (a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7";
    else if (a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7";

    return 0;
}

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

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int A[N][M],B[M],ans=0;
    for(int i=0;i<M;i++){
        cin >> B[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
    for(int i=0,res=0;i<N;i++,res=0){
        for(int j=0;j<M;j++){
            res+=A[i][j]*B[j];
        }
        res+=C;
        if(res>0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
int n;
string s;
bool a[maxn]; //s=0 w=1

void gogo(int A,int B){
    a[0]=A,a[1]=B;
    for(int i=2;i<n;i++){
        a[i]=(a[i-1])^(s[i-1]=='o')^a[i-2];
    }
    if(a[0]^a[n-2]^a[n-1]^(s[n-1]=='o')) return;
    if(a[1]^a[0]^a[n-1]^(s[0]=='o')) return;
    REP(i,n){
        if(a[i]) cout<<'S';
        else cout<<'W';
    }
    cout<<'\n';
    exit(0);
}

int main()
{
	IOS;
	cin>>n>>s;
	
	REP(i,2) REP(j,2) gogo(i,j);
	cout<<-1;
}


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

int main(void){
  int A[3];
  cin >> A[0] >> A[1] >> A[2];

  int minScore = -1;

  // 3!パターン存在する
  for (int i = 0; i < 6;i++){
    int score = 0;
    int preIndex;
    for (int j = 0; j < 3; j++)
    {
      int index = ((i / 2) + j * ((i % 2) * 2 - 1) + 3) % 3;

      if (j == 0){
        preIndex = index;
        continue;
      }

      score += A[index] - A[preIndex] > 0 ? A[index] - A[preIndex] : A[preIndex] - A[index];

      preIndex = index;
    }
    if(minScore==-1 || minScore>score){
      minScore = score;
    }
  }

  cout << minScore << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, K;
bool kasi[110];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int cnt = 0;
    cin >> N >> K;
    for(int i = 0; i < K; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            kasi[a] = true;
        }
    }
    for(int i = 1; i <= N; i++) if(!kasi[i]) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=1;i<=n;i++) cin>>a[i];
	int k=1,s=0;
	b[1]=k;
	for(int i=2;i<=n;i++){
		if(a[i]==a[i-1]) b[i]=k;
		else{
			k++;
			b[i]=k;
		} 
	}
	k=1;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(b[i]==k) s++;
		if(b[i+1]!=k||i==n){
			if(s==1) ans+=0;
			else ans+=s/2;
			k++; 
			s=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define fi first
#define se second 
#define pb push_back
int cst[30004];
int a[1003];
int b[1003];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h,n; 
	cin>>h>>n; 
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	memset(cst,0x3f,sizeof cst);
	int ans = cst[0];
	cst[0] = 0;
	for(int i=1;i<30004;i++){
		for(int j=0;j<n;j++){
			if(i-a[j]<0)continue;
			cst[i] =min(cst[i],cst[i-a[j]]+b[j]);
		}
	}
	for(int i=h;i<30004;i++){
		ans = min(ans,cst[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var searchTxt string
	var i, result int
	for sc.Scan() {
		input := strings.Split(sc.Text(), " ")
		if i == 0 {
			searchTxt = strings.ToLower(input[0])
		} else if input[0] == "END_OF_TEXT" {
			break
		} else {
			for _, word := range input {
				if strings.ToLower(word) == searchTxt {
					result++
				}
			}
		}
		i++
	}
	fmt.Println(result)
}



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

using namespace std;

int p[25];

int n;

int main(void) {

	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}

	int ans = 0;

	for (int i = 2; i <= n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) { ans++; }
		else if (p[i - 1] > p[i] && p[i] > p[i + 1]) { ans++; }
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int cntAC=0, cntWA=0, cntTLE=0, cntRE=0;
  for(int i = 0; i < n; i++) {
    string S;
    cin >> S;
    if (S == "AC") cntAC++;
    if (S == "WA") cntWA++;
    if (S == "TLE") cntTLE++;
    if (S == "RE") cntRE++;
  }
  cout << "AC x " << cntAC << endl;
  cout << "WA x " << cntWA << endl;
  cout << "TLE x " << cntTLE << endl;
  cout << "RE x " << cntRE << endl;
}

Measured memory_bytes: 3500
#include <bits/stdc++.h> 
#define rr(i,n)  for(int i=0; i<n; i++)
#define ol(a) cout << a << endl;
using namespace std;

int main(){
  int64_t n;  cin >> n;
  string s; cin >> s;
  int a = s.size();
  if(a<=n){
    ol(s);
  }
  else {
    rr(i,n){
      cout << s.at(i);
    }
    ol("...")
  }
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    int p;
    if (k % 2 == 0) p = 1;
    else p = -1;
    cout << (a - b) * p << endl;
    return 0;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long D, N;
    scan(D, N);
    if (N == 100)
    {
        writeln("101" ~ repeat('0').take(D * 2).array);
    }
    else
    {
        writeln(text(N) ~ repeat('0').take(D * 2).array);
    }
}


Measured memory_bytes: 256
//============================================================================
// Name        : CompleteBinaryTree.cpp
// Author      : Ken
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
using namespace std;

class BinaryHeap{
private:
	vector<int> contents;

public:
	BinaryHeap(){}

	void insert(int elem){
		contents.push_back(elem);
	}

	void writeHeap(){
		for(int i=0; i<contents.size(); i++){
			writeContent(i);
		}
	}

	void writeContent(int index){
		cout << "node " << index+1 << ": key = " << contents.at(index) << ", ";

		int parent_index = (index+1)/2 - 1;
		int left_index = (index+1) * 2 - 1;
		int right_index = (index+1) * 2;
		if(parent_index >= 0){
			cout << "parent key = " << contents.at(parent_index) << ", ";
		}
		if(left_index < contents.size()){
			cout << "left key = " << contents.at(left_index) << ", ";
		}
		if(right_index < contents.size()){
			cout << "right key = " << contents.at(right_index) << ", ";
		}
		cout << "\n";
	}
};

int main() {
	int n, input;
	BinaryHeap bh;

	cin >> n;
	for(int i=0; i<n; i++){
		cin >> input;
		bh.insert(input);
	}

	bh.writeHeap();
}



Measured memory_bytes: 3160
#include <stdio.h>
#include <stdlib.h>
int n[6], x, y, a3, b3;
int mat[3][3];

void f(int p, int num){
    if(p == 3){
        /*for(int i=0; i<4; i++){
            printf("%d ", n[i]);
        }*/
        n[p] = num;
        x = mat[0][0] - n[0];
        y = mat[1][0] - n[1];
        if(x == y && x == n[2]){
            x = mat[1][1] - n[1];
            y = mat[0][1] - n[0];
            if(x == y && x == n[3]){
                if(mat[2][0]-n[2] == mat[2][1]-n[3]){
                    a3 = mat[2][0] - n[2];
                    if(mat[0][2]-n[0] == mat[1][2]-n[1]){
                        b3 = mat[0][2] - n[0];
                        if(a3 + b3 == mat[2][2]){
                            printf("Yes\n");
                            exit(0);
                        }
                    }
                }
            }
        }
        return;
    }
    n[p] = num;
    for(int i=0; i<=100; i++){
        f(p+1, i);
    }
}

int main(){
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            scanf("%d", &mat[i][j]);
        }
    }
    for(int i=0; i<=100; i++){
        f(0,i);
    }
    printf("No\n");
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		long result = 0;
		long t = 1;
		long a = 1;
		for(int i = 0; i < n; i++){
		    long nt = sc.nextLong();
		    long na = sc.nextLong();
		    long cnt = max((t + nt - 1)/nt, (a + na - 1)/na);
		    t = nt*cnt;
		    a = na*cnt;
		}
		result = t + a;
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 2000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    for(int i = 0;i < 2;i++) {
        if(A > B) {
            swap(A,B);
        }
        if(B > C) {
            swap(B,C);
        }
    }
    int ret = 0;
    if(A % 2 != B % 2) {
        C++;
        A++;
        ret++;
    }
    ret += (B - A) / 2;
    A = B;
    ret += C - B;
    cout << ret << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

vector<pair<ll, int> > primeFactorize(ll n) {
  vector<pair<ll, int> > res;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i) continue;
    res.push_back(make_pair(i, 0));
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	ll n;
	cin >> n;
	vector<pair<ll, int> > v = primeFactorize(n);
	int res = 0;
	rep (i, v.size()) {
	  int cnt = 0;
	  for (int j = 1; ; ++j) {
		cnt += j;
		if (cnt >= v[i].second) {
		  res += j;
		  if (cnt != v[i].second) res--;
		  break;
		}
	  }
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int INF = 1e9;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,M;
    cin >> N >> M;
    if(N == M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.math.BigDecimal;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		while ( sc.hasNext() ) {
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			double c = sc.nextDouble();
			double d = sc.nextDouble();
			double e = sc.nextDouble();
			double f = sc.nextDouble();

			double x = (c*e - b*f) / (a*e - b*d);
			double y = (c - a*x) / b;

			BigDecimal bdx = new BigDecimal(x);
			BigDecimal bdy = new BigDecimal(y);

			bdx = bdx.setScale(3, BigDecimal.ROUND_HALF_UP);
			bdy = bdy.setScale(3, BigDecimal.ROUND_HALF_UP);

			System.out.println(bdx + " " + bdy);
		}
	}

}

Measured memory_bytes: 28648
K = int(input())

if K % 2 == 0:
    print(-1)
elif K % 5 == 0:
    print(-1)
else:
    seven = 7
    ans = 1
    while ans < 1000000:
        amari = seven % K
        if amari == 0:
            print(ans)
            break
        else:
            ans += 1
            seven = amari * 10 + 7
    else:
        print(-1)

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

using namespace std;

long long n, k, x, MOD, mmin, mmax, ans;

main(){
    MOD = 1e9 + 7;
    cin >> n >> k;
    mmin = 0;
    mmax = n;
    for (int i = 1; i < k; i++){
        mmin += i;
        mmax += (n - i);
    }
    ans = 0;
    for (int i = k; i <= n + 1; i++){
        ans = (ans + mmax - mmin + 1) % MOD;
        mmax += (n - i);
        mmin += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import sys

# print('input >>')
N = int(input())
As = list(map(int,(input().split())))

INF = 10 ** 18

ans = 1

over = False

for A in As:
    if A == 0:
        print(0)
        sys.exit()

for A in As:
    ans *= A
    if ans > INF:
        print(-1)
        sys.exit()
        
# print('-----output-----')
print(ans)


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

int main() {
  int N ; 
  cin >> N ;
  vector<int> W(N) , M(N)  ; 
  int R = 0 ; 
  int L = 0 ; 
  
  for(int i = 0 ; i < N ; i++){
    cin >> W.at(i) ; 
  }
  
  for(int i = 0 ; i < N ; i++){//仕切り
    
      for(int j = 0 ; j < N ; j++){ 
        if( i <  j ){ //仕切りが左
			L = L + W.at(j) ; 
        }
        else{
            R = R + W.at(j) ; 
        }

      }
    
    //cout << L << " "<< R << endl ;
    M.at(i) = abs(L - R) ; 
    L = 0 ; 
    R = 0 ; 
  }
  
  sort(M.begin(),M.end()) ; 
  cout << M.at(0) << endl ; 
  
}

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

int main(){
  int n,a=0;cin >> n;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(n==i*j){a=1;}
    }
  }
  if(a==1){
    cout << "Yes"<<endl;
  }else{
    cout << "No"<<endl;
  }
}

Measured memory_bytes: 256
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

A, B = rl()
grid = [['.'] * 100 for _ in range(50)] + [['#'] * 100 for _ in range(50)]
for i in range(B-1):
    row, column = divmod(i, 50)
    row *= 2
    column *= 2
    grid[row][column] = '#'

for i in range(A-1):
    row, column = divmod(i, 50)
    row *= 2
    column *= 2
    grid[99-row][column] = '.'
print(100,100)
for x in grid:
    print(*x, sep='')
#56

Measured memory_bytes: 13872
// PCA.cpp :
//#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
	int N;
	cin>>N;
	int count = 0;
	for (int i = 1; i < N; i++)
	{
		int j = N - i;
		if (i != j) {
			count++;
		}
	}
	cout << count / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

#define MAX 1000007

class Edge{
public:
    ll t,w;
    Edge(ll t,ll w):t(t),w(w){}
};

vector<Edge> G[MAX];
ll N,d[MAX];

bool vis[MAX];
ll cnt;

void bfs(ll s){
    rep(i,N){
        d[i]=LINF;
    }
    queue<ll> Q;
    Q.push(s);
    d[s]=0;
    ll u;
    while(!Q.empty()){
        u=Q.front();Q.pop();
        rep(i,G[u].size()){
            Edge e = G[u][i];
            if(d[e.t]==LINF){
                d[e.t]=d[u]+e.w;
                Q.push(e.t);
            }
        }
    }
}

void solve(){
    // 適当な点 s から最も遠い節点 tgt を求める
    bfs(0);

    ll maxv=0;
    ll tgt=0;

    rep(i,N){
        if(d[i]==LINF){
            continue;
        }
        if(maxv<d[i]){
            maxv=d[i];
            tgt=i;
        }
    }

    // tgt から最も遠い節点の距離 maxv を求める
    bfs(tgt);

    rep(i,N){
        if(d[i]==LINF){
            continue;
        }
        maxv=max(maxv,d[i]);
    }

    cout << maxv << endl;
}

int main(){
    ll s,t,w;
    cin >> N;
    rep(i,N-1){
        cin >> s >> t >> w;
        G[s].pb(Edge(t,w));
        G[t].pb(Edge(s,w));
    }
    solve();
}


Measured memory_bytes: 32900
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v) {std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

#define EPS 1e-8
#define EQ(a, b) (abs((a)-(b)) < EPS)

typedef complex<double> P;

double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

int ccw(P p0, P p1, P p2) {
    p1 -= p0;
    p2 -= p0;
    if (cross(p1, p2) > EPS) return 1; //ccw
    if (cross(p1, p2) < -EPS) return -1; //cw
    if (dot(p1, p2) < -EPS) return 2; //left
    if (abs(p1) < abs(p2)) return -2; //right
    return 0; //mid
}

int main() {

    double xp0, yp0, xp1, yp1;
    cin >> xp0 >> yp0 >> xp1 >> yp1;

    P p0(xp0, yp0);
    P p1(xp1, yp1);

    int Q;
    cin >> Q;

    while (Q--) {

        double xp, yp;
        cin >> xp >> yp;

        P p2(xp, yp);

        int ans = ccw(p0, p1, p2);

        string s = "";
        if (ans == 1) s = "COUNTER_CLOCKWISE";
        if (ans == -1) s = "CLOCKWISE";
        if (ans == 2) s = "ONLINE_BACK";
        if (ans == -2) s = "ONLINE_FRONT";
        if (ans == 0) s = "ON_SEGMENT";

        cout << s << endl;
    }

    return 0;
}














































Measured memory_bytes: 3344
#include <stdio.h>

int main(void){
    int N,M,i,sum,f;
    int A[10000];
    
    scanf("%d",&N);
    scanf("%d",&M);
    
    for(i=0;i<M;i++){
        scanf("%d",&A[i]);
    }
    
    sum=0;
    for(i=0;i<M;i++){
        sum=sum+A[i];
    }
    
    f=N-sum;
    
    if(f<0){
        f=-1;
    }
    
    printf("%d\n",f);
    
    return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    int c = 0;
    int n, a;
    cin >> n;
    REP(i, n) {
        cin >> a;
        c = (c + a % 2) % 2;
    }
    cout << ((c == 1)?"NO":"YES") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int a,b,C;
    cin >> a >> b >> C;
    double rad,PI = acos(-1);
    rad = C*PI/180;
    double S = a*b*sin(rad)/2;
    double c = sqrt(a*a+b*b-2*a*b*cos(rad));
    double L = a+b+c;
    double h = b*sin(rad);
    printf("%.5f\n%.5f\n%.5f\n",S,L,h);
    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < int(n); i++)
using namespace std;
 
int main() {
    int a,b,f;
    cin >> a >> b;
    f = max(max(a+b,a-b),a*b);
    cout << f << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll p[51] = {};
int main() {
	ll n; cin >> n;
	ll cnt = 0;
	rep(i, 0, n) {
		cin >> p[i];
		if (p[i] != i+1)cnt++;
	}
	if (cnt <= 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}




	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long

int main(){
	ll N,M;
	cin>>N>>M;
	priority_queue<double> A;
	for(int i=0;i<N;i++){
		int tmp;
		cin>>tmp;
		A.push(tmp);
	}
	for(int i=0;i<M;i++){
		double tmp=A.top();
		A.pop();
		A.push(tmp/2);
	}
	ll ans=0;
	for(int i=0;i<N;i++){
		ans+=(ll)A.top();
		A.pop();
	}
	cout<<ans;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a / gcd(a,b)) * b; }
ll gcd2(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {   x = 1;  y = 0;  return a;   }
    ll xx, yy;
    ll res = gcd2(b, a%b, xx, yy);
    x = yy;     y = xx - yy * (a / b);
    return res;
}

// ll nCr(ll n, ll r) {
//     return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod );
// }
// const ll sz = 1e6 + 5;
// vector<ll> fac(sz, 1);

// * ALways PASS arrays, strings etc to functions BY REFERENCE

set<int> ps;

bool func(int val) {
    int x = val;
    for (int i = 2; i*i <= val; i++) {
        if (x % i != 0)
            continue;

        if (ps.count(i))
            return false;
        else
            ps.insert(i);
        
        while (x % i == 0)
            x /= i;
    }
    
    if (x != 1) {
        if (ps.count(x))
            return false;
        else
            ps.insert(x);
    }
    
    return true;
}


int main() {
    // for (int i = 1; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    int t = 1;
    // cin >> t;
    
    while(t--) {
        int n;
        cin >> n;
        
        vector<int> arr(n);
        for (auto &x: arr)
            cin >> x;
        
        bool f = true;
        for (int i = n-1; i >= 0; i--) {
            if (!func(arr[i])) {
                f = false;
                break;
            }
        }
        
        if (f) {
            cout << "pairwise coprime" << endl;
            return 0;
        }
        
        int g = arr[0];
        for (int i = 1; i < n; i++)
            g = gcd(g, arr[i]);
        
        if (g == 1) {
            cout << "setwise coprime" << endl;
            return 0;
        }
        
        cout << "not coprime" << endl;
    }
    
	return 0;
}


Measured memory_bytes: 7288
n, m = map(int, input().split())
l_r = [ list(map(int, input().split())) for _ in range(m) ]

l_ans = 0
r_ans = float('inf')
for l, r in l_r:
    l_ans = max(l_ans, l)
    r_ans = min(r_ans, r)
if r_ans < l_ans:
    ans = 0
else:
    ans = r_ans-l_ans+1
print(ans) 

Measured memory_bytes: 27032
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let () =
  let n = read_int () in
  let rec doit turn p1 p2 =
    if turn > n then Printf.printf "%d %d\n" p1 p2
    else
      let l = read_line () in
      match split l ' ' with
      | [] | [_] -> exit 1
      | c1 :: c2 :: _ ->
          if c1 = c2 then doit (turn + 1) (p1 + 1) (p2 + 1)
          else if c1 < c2 then doit (turn + 1) p1 (p2 + 3)
          else doit (turn + 1) (p1 + 3) p2
  in
  doit 1 0 0

Measured memory_bytes: 2456
N=input()
M=len(raw_input())
O=10**9+7
D=[pow(-~O//2,M,O)]+[0]*N
for _ in'_'*N:D=[D[0]+D[1]]+[(i+2*j)%O for i,j in zip(D[2:]+[0],D[:-1])]
print D[M]

Measured memory_bytes: 73244
// see: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut 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;

fn main() {
    input!{
        a: usize, b: usize, m: usize,
        aseq: [usize; a],
        bseq: [usize; b],
        cseq: [(usize, usize, usize); m]
    }

    let mut min_price =
        aseq.iter().min().unwrap() + bseq.iter().min().unwrap();

    for (a, b, c) in cseq {
        min_price = cmp::min(min_price, aseq[a - 1] + bseq[b - 1] - c)
    }

    println!("{}", min_price);

}


Measured memory_bytes: 14456
#include <bits/stdc++.h>
using namespace std;
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// input a letter
	template <class I>
	inline void get (I &x) {
		for (c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		x = c;
	}
	// input a string
	inline void read (char *s){
		for(c = gc(); c < 'A' || c > 'Z'; c = gc()) ;
		for(; c >= 'A' && c <= 'Z'; c = gc()) *++s = c;
		*++s = '\0';
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	//no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}
using io :: gi;
using io :: get;
using io :: read;
using io :: putc;
using io :: print;
inline void add(ri x,ri y){
	print(x);putc(' ');print(y);putc('\n');
}
int main(){
	ri n,k,i;
	gi(n);
	if(__builtin_popcount(n)==1) return puts("No"),0;
	puts("Yes");
	for(i=2;i+1<=n;i+=2)
		add(i+1,i),add(i,n+1),add(n+1,n+i+1),add(n+i+1,n+i);
	add(1,3);
	if(~n&1){
		k=0;
		while(1<<k+1<n) ++k;
		add(n,1<<k);
		add((n<<1)-(1<<k)+1,n<<1);
	}
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

ll a,b,c,d;

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	a=read(),b=read(),c=read(),d=read();
	ll cnt1=a*c;
	ll cnt2=a*d;
	ll cnt3=b*c;
	ll cnt4=b*d;
	ll res=max(cnt1,max(cnt2,max(cnt3,cnt4)));
	printf("%lld\n",res);

    return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();
        int w = tx - sx;
        int h = ty - sy;
        for (int i = 0; i < h; i++) {
            System.out.print('U');
        }
        for (int i = 0; i < w; i++) {
            System.out.print('R');
        }
        for (int i = 0; i < h; i++) {
            System.out.print('D');
        }
        for (int i = 0; i < w; i++) {
            System.out.print('L');
        }
        System.out.print('L');
        for (int i = 0; i < h + 1; i++) {
            System.out.print('U');
        }
        for (int i = 0; i < w + 1; i++) {
            System.out.print('R');
        }
        System.out.print('D');
        System.out.print('R');
        for (int i = 0; i < h + 1; i++) {
            System.out.print('D');
        }
        for (int i = 0; i < w + 1; i++) {
            System.out.print('L');
        }
        System.out.println('U');
    }
}


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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    int n, l; cin >> n >> l;
    priority_queue<string, vector<string>, greater<string>> q;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        q.push(s);
    }
    while (!q.empty()) {
        cout << q.top();
        q.pop();
    }
    cout << NL;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

namespace ABC085B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Dictionary<int, int> d = new Dictionary<int, int>();
            for(int a = 0; a < n; a++)
            {
                int input = int.Parse(Console.ReadLine());
                if (!d.ContainsKey(input))
                {
                    d.Add(input, 1);
                }
            }

            Console.WriteLine(d.Count);

        }
    }
}

Measured memory_bytes: 13152
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	r := nextInt()
	if n < 10 {
		r += 100 * (10 - n)
	}

	_, _ = fmt.Fprintf(writer, "%d", r)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

int main()
{	
	int ans=0, i, j, k;
	int n, p[110] = {0}, P[110] = {0};
	string s[110], S[110];
	cin >> n;
	for (i = 0; i < n;i++){
		cin >> s[i] >> p[i];
		S[i] = s[i];
		P[i] = p[i];
	}

	for (i = 0; i < n-1;i++){
		for (j = i+1; j < n;j++){
			if(s[i]>s[j]){
				string temp = s[i];
				s[i] = s[j];
				s[j] = temp;
				int t = p[i];
				p[i] = p[j];
				p[j] = t;
			}
		}
	}
	for (i = 0; i < n-1;i++){
		for (j = i+1; j < n;j++){
			if(s[i]==s[j]){
				if(p[i]<p[j]){
				int t = p[i];
				p[i] = p[j];
				p[j] = t;
				}
			}
		}
	}

	int a[110] = {0};
	for (i = 0; i < n;i++){
		for (j = 0; j < n; j++){
			if((S[j]==s[i])&&(P[j]==p[i])){
				a[i] = j + 1;
			}
		}
	}
	for (i = 0; i < n; i++){
		cout << a[i] << endl;
	}
	return 0;
}

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

int main(){
  int N,H;
  cin>>N>>H;
  vector<pair<int,int>> damage;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    damage.push_back(make_pair(a,0));
    damage.push_back(make_pair(b,1));
  }
  sort(damage.begin(),damage.end());
  reverse(damage.begin(),damage.end());

  int sum=0;
  int counter=0;
  for(int i=0;i<2*N;i++){
    if(sum>=H){
      cout<<counter<<endl;
      break;
    }
    if(damage.at(i).second==1){
      sum+=damage.at(i).first;
      counter++;
    }else{
      cout<<counter+(H-sum-1)/damage.at(i).first+1<<endl;
      break;
    }
  }
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    string S;
    cin >> S;

    for (int i = 0; i < S.size(); i++)
    {
        if (i % 2 == 0)
        {
            printf("%c", S[i]);
        }
    }
    printf("\n");
    return (0);
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define n 4
#define T 1
#define F 0

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

void swap(int *x,int *y){
  int tp=*x;
  
  *x=*y;
  *y=tp;
  
  return ;
}

int getH(){
  int i,j,sum=0,x;
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(t[i][j]==0)continue;
      x=t[i][j]-1;
      sum+=abs(x/4-i)+abs(x%4-j);
    }
  }
  
  return sum;
}

int dfs(int d,int pr,int py,int px){
  int h=getH();
  
  if(h==0)return T;
  if(d+h>lim)return F;
  int i;
  
  for(i=0;i<4;i++){
    
    if(abs(i-pr)==2)continue;
    int tx=px+dx[i],ty=py+dy[i];
    if(tx<0||ty<0||tx>=n||ty>=n)continue;
    swap(&t[ty][tx],&t[py][px]);
    if(dfs(d+1,i,ty,tx))return T;
    swap(&t[ty][tx],&t[py][px]);
  }
  
  return F;
}

void isS(int py,int px){
  
  for(lim=0;;lim++){
    if(dfs(0,99,py,px)){
      printf("%d\n",lim);
      return ;
    }
  }
}

int main(){
  int i,j,px,py;
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&t[i][j]);
      if(t[i][j]==0){
	py=i;
	px=j;
      }
    }
  }
  
  isS(py,px);
  
  return 0;
}




Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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

int main() {
  int n, q, total = 0;
  cin >> n;

  vi s(n);
  rep(i, n) cin >> s[i];
  
  cin >> q;
  rep(i, q) {
    int t;
    cin >> t;

    auto a = lower_bound(s.begin(), s.end(), t);

    if (t == *a) total++;
  }

  cout << total << endl;
}



Measured memory_bytes: 3096
N,D = map(int,input().split())
l =[list(map(int,input().split())) for i in range(N)] 
c = 0
for i in range(N):
    if (l[i][0]**2+l[i][1]**2)**0.5<=D:
        c+=1
    else:
        pass
print(c)

Measured memory_bytes: 45788
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int s[] = new int[n];
		for(int i=0; i<n; i++) {
			s[i]=sc.nextInt();
		}
		int MAX = 10005;
		boolean dp[][] = new boolean[n+1][MAX];
		for(int i=0; i<n; i++) {
			for(int j=0; j<MAX; j++) {
				dp[i][j] = false;
			}
		}
		dp[0][0]=true;
		for(int i=0; i<n; i++) {
			for(int j=0; j<MAX; j++) {
				if(!dp[i][j]) continue;
				dp[i+1][j+s[i]] = true;
				dp[i+1][j] = true;
			}
		}
		int ans = 0;
		for(int i=0; i<MAX; i++) {
			if(dp[n][i] && i%10 != 0) {
				ans = i;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 38036
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    int M1,D1,M2,D2;
    cin>>M1>>D1>>M2>>D2;

    if(M1!=M2)
    {
        cout<<"1"<<endl;
    }
    else{
        cout<<"0"<<endl;
    }
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int h, w;
	cin >> h >> w;
	vector<string> in(h);
	rep(i, h) cin >> in[i];
	
	auto get = [&](){
		//dbg(h, w); dbg(in);
		vector<vi> res(h, vi(w));
		rep(i, h){
			for(int j = w - 1; j >= 0; j--){
				if(in[i][j] == '#') continue;
				res[i][j] = j + 1 == w ? 1 : res[i][j + 1] + 1;
			}
		}
		vector<string> rot(w, string(h, '.'));
		rep(i, h) rep(j, w) rot[j][h - i - 1] = in[i][j];
		swap(w, h);
		in = rot;
		return res;
	};
	
	vector<vector<vi>> beam;
	rep(i, 4) beam.pb(get());
	
	//dbg(beam);
	
	int ans = 0;
	rep(i, h) rep(j, w){
		ans = max(ans, 
			beam[0][i][j] + 
			beam[1][j][h - i - 1] +
			beam[2][h - i - 1][w - j - 1] +
			beam[3][w - j - 1][i] - 3);
	}
	cout << ans << endl;
	
	return 0;
}

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


int dp[100005][4];
struct me
{
    int x,y,z;

}a[100005];
int n;

int func(int pos,int nichi_kon_ta)
{
    if(pos==n)return 0;

    if(dp[pos][nichi_kon_ta]!=-1)return dp[pos][nichi_kon_ta];

    int p=0,q=0,r=0;

    if(nichi_kon_ta==1 || nichi_kon_ta==0)
    {
        p=max(a[pos].y+func(pos+1,2),a[pos].z+func(pos+1,3));
    }

    if(nichi_kon_ta==2 || nichi_kon_ta==0)
    {
        q=max(a[pos].x+func(pos+1,1),a[pos].z+func(pos+1,3));
    }

    if(nichi_kon_ta==3  || nichi_kon_ta==0)
    {
        r=max(a[pos].y+func(pos+1,2),a[pos].x+func(pos+1,1));
    }

    return dp[pos][nichi_kon_ta]=max({p,q,r});
}

int main()
{
    memset(dp,-1,sizeof dp);

    scanf("%d",&n);

    for(int i=0;i<n;i++)scanf("%d %d %d",&a[i].x,&a[i].y,&a[i].z);

    printf("%d",func(0,0));

    return 0;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int c[3][3];

	//int x,y,z,a1,a2,a3,b1,b2,b3;

	f(i,0,2)
	{
	    f(j,0,2){
            cin>>c[i][j];
	    }
	}

    int a[3],b[3];

    for(a[0]=0;a[0]<=100;a[0]++)
    {
        for(a[1]=0;a[1]<=100;a[1]++)
        {
            for(a[2]=0;a[2]<=100;a[2]++){
                b[0]=c[0][0]-a[0];
                b[1]=c[0][1]-a[0];
                b[2]=c[0][2]-a[0];

                count=0;
                f(i,0,2){
                    f(j,0,2){
                        if(c[i][j]==a[i]+b[j]) count++;
                    }
                }
                if(count==9) cout<<"Yes"<<endl,exit(0);

            }
        }
    }
	cout<<"No"<<endl;
}


Measured memory_bytes: 256