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

typedef long long int ll;
#define rep(i,n) for(int i = 0; i < n; i++)
#define MOD 1000000007

int check(ll a, ll b, ll c) {
  return (a+b>c && b+c>a && c+a>b && a!=b && b!=c && c!=a);
}

int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      for(int k = j+1; k < n; k++) {
        ans += check(a[i],a[j],a[k]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define IO(x,y) freopen(x,"r",stdin);freopen(y,"w",stdout)
#define fo(x) while(x-->0)
#define nl '\n'
#define pb push_back

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// IO("in.txt", "out.txt");
	int n, m;
	string s1, s2;
	stack<int> terstenoutput;
	cin >> s1 >> s2;
	n=s1.length()+1;
	m=s2.length()+1;
	int dp[n][m];
	int i, j;
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			if(i && j){
				if(s1[i-1]==s2[j-1])
					dp[i][j]=dp[i-1][j-1]+1;
				else
					dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
			}
			else
				dp[i][j]=0;
		}
	}
	// cout << dp[n-1][m-1] << nl;
	i=n-1;
	j=m-1;
	while(i && j){
		if(dp[i][j]==dp[i-1][j]){
			i--;
		}
		else if(dp[i][j]==dp[i][j-1]){
			j--;
		}
		else{
			i--; j--;
			terstenoutput.push(i);
		}
	}
	while(!terstenoutput.empty()){
		cout << s1[terstenoutput.top()];
		terstenoutput.pop();
	}
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=200005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int power(int x, int y, int p)
{
    int res = 1;   
    x = x % p; 
    while (y > 0)
    {
        if (y & 1)
            res = (1LL*res*x) % p;
 
        y = y>>1;
        x = (1LL*x*x) % p;
    }
    return res;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
lli fac[N];
void fact(){
	for(int i=2;i<N;i++)
		fac[i]=(1ll*fac[i-1]*i)%mod;
}
int main(){
	fast
	int h,w,n,x,y;
	cin>>h>>w>>n;
	vector<pii>v;
	map<pii,lli>dis;
	FOR0(n){
		cin>>x>>y;
		v.pb({x,y});
	}
	fac[0]=fac[1]=1;
	fact();
	lli tot=fac[h+w-2];//total number of paths in the grid from top to bottom
	tot=(tot*modInverse(fac[h-1],mod))%mod;
	tot=(tot*modInverse(fac[w-1],mod))%mod;
	sort(all(v));
//	cout<<tot<<endl;
	lli subtract=0;
	for(int i=0;i<n;i++){
		x=v[i].ff;y=v[i].ss;x--;y--;
		lli till_here_tot=fac[x+y];//tot paths from 0,0 to this stone
		till_here_tot=(till_here_tot*modInverse(fac[x],mod))%mod;
		till_here_tot=(till_here_tot*modInverse(fac[y],mod))%mod;
	//	cout<<till_here_tot<<endl;
		lli repeat=0;
		for(int j=0;j<i;j++){
			int xx=v[j].ff,yy=v[j].ss;xx--;yy--;
			if(yy>y) continue;
			lli m=x-xx,n=y-yy;
			lli path=fac[m+n];
			path=(path*modInverse(fac[m],mod))%mod;
			path=(path*modInverse(fac[n],mod))%mod;
			repeat=(repeat+(dis[{xx,yy}]*path)%mod)%mod;
		}
		dis[{x,y}]=(till_here_tot-repeat+mod)%mod;
	//	cout<<dis[{x,y}]<<endl;
		lli xx=h-1-x,yy=w-1-y;
	//	cout<<xx<<" "<<yy<<endl; 
		lli till_end=(fac[xx+yy]*modInverse(fac[xx],mod))%mod;
		till_end=(till_end*modInverse(fac[yy],mod))%mod;
	//	cout<<till_end<<endl;
		lli tot_sub=(till_end*dis[{x,y}])%mod;
		subtract=(subtract+tot_sub)%mod;
	}
	lli an=(tot-subtract+mod)%mod;
	cout<<an;
}

Measured memory_bytes: 2048
import math
a, b, h, m = list(map(int, input().split()))

h = h + m / 60

theta = min(abs(h/6 - m/30)*math.pi, 2*math.pi - abs(h/6 - m/30)*math.pi)
s = math.sqrt(a**2+b**2-2*a*b*math.cos(theta))

print(s)

Measured memory_bytes: 62412
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<lnt> a(n);
	rep(i,n) std::cin >> a[i];
	for(int i=k+1;i<=n;i++) {
		if(a[i-1]>a[i-k-1]) print("Yes");
		else print("No");
	}
}


Measured memory_bytes: 4780
import math

A, B = map(int,input().split())

pricemax_A = math.floor((A+1)/0.08)
pricemin_A = math.ceil(A/0.08)

pricemax_B = math.floor((B+1)/0.1)
pricemin_B = math.ceil(B/0.1)

if pricemin_A >= pricemin_B and pricemin_A < pricemax_B:
    print(pricemin_A)
elif pricemin_A <= pricemin_B and pricemax_A > pricemin_B:
    print(pricemin_B)
else:
    print(-1)


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

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static int n = 0;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0;i < n;i++){
			h[i] = sc.nextInt();
					
		}
		Arrays.sort(h);
		long ans = 1000000000;
		for(int i = 0;i + k -1 < n;i++){
			ans = Math.min(ans, h[i+k-1] - h[i]);
		}
		System.out.println(ans);
			
				
	}

}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


Measured memory_bytes: 50320
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define ull unsigned long long

using namespace std;

typedef pair<int, int> pii;

const int MAX_N = 1e2 + 10, MAX_K = 1e5 + 10, MOD = 1e9 + 7;
int n, k, a[MAX_N], dp[MAX_N][MAX_K];

main (){
	cin >> n >> k;
	for (int i = 1 ; i <= n ; i++)
		cin >> a[i];
	dp[0][0] = 1;
	for (int i = 1 ; i <= n ; i++){
		int sum = 0;
		for (int j = 0 ; j <= k ; j++){
			if (j > a[i]){
				sum += dp[i - 1][j] - dp[i - 1][j - a[i] - 1];
			}
			else {
				sum += dp[i - 1][j];
			}
			dp[i][j] = (sum + MOD) % MOD;
		}
	}
	cout << dp[n][k];
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	long long int a;
	cin >> t;
	int d = t;
	long long int sum = 0;
	long long int sum2 = 0;
	long long int mod = 1000000007;
	vector<long long int> v;
	while(t--){
		cin>>a;
		v.push_back(a);
		sum+=a;
	}
	for(int i=0;i<d;i++){
		sum-=v[i];
		sum2 += (sum%mod*v[i]%mod)%mod;
	}
	sum2%=mod;
	cout << sum2 << endl;
		
	return 0;
}



Measured memory_bytes: 5332
# coding: utf-8
# Your code here!



def printStr(i):
    for j in range(3):
        print(nums[j], end = "")
        print(lst[-1][i][j], end = "")
    print(nums[3], end = "")
    print("=7")

str=list(input())
nums = []
for i in range(4):
    nums.append(int(str[i]))

lst = []
tmp = []


for i in range(3):
    if len(lst) == 0:
        tmp = ['+', '-']
        lst.append(tmp)
    else:
        tmp = []
        for j in range(len(lst[-1])):
            tmp.append(lst[-1][j] + "+")
            tmp.append(lst[-1][j] + "-")
        lst.append(tmp)

for i in range(len(lst[-1])):
    result = nums[0]
    for j in range(len(lst[-1][i])):
        
        if lst[-1][i][j] == "+":
            result += nums[j + 1]
        else:
            result -= nums[j + 1]
            
        if j == 2 and result == 7:
            printStr(i)
            exit()
    
        











Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
 int h,n;
 scanf("%d%d",&h,&n);
 int skill[n];
 for(int i=0;i<n;i++){
     scanf("%d",&skill[i]);
 }
 int sum=0;
 for(int i=0;i<n;i++){
     sum+=skill[i];
 }
 if(sum>=h){
     printf("Yes");
 }else{
     printf("No");
 }
 return 0;
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;


void Main(){
   int a,b;
   cin >> a >> b;
   
  string ans;
  if(a==b){
      ans = "Draw";
  }
  else if(a==1){
      ans = "Alice";
  }
  else if(b==1){
       ans = "Bob";
  }
  else if(a>b){
    ans = "Alice";
  }
  else{
  ans = "Bob";
  }
  cout << ans << endl;
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;

    int start, end;
    rep(i, s.size()) if (s[i] == 'A') {
        start = i;
        break;
    }
    rep(i, s.size()) if (s[s.size() - i - 1] == 'Z') {
        end = s.size() - i - 1;
        break;
    }

    put(end - start + 1);
    
    return 0;
}

Measured memory_bytes: 3732
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
int l[300000], r[300000];
vector<int> range[100001];
int bit[100001], n;
int sum(int i) {
	int s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i&-i;
	}
	return s;
}
void add(int i, int x) {
	while (i <= n) {
		bit[i] += x;
		i += i&-i;
	}
}
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
		range[r[i] - l[i] + 1].push_back(i);
	}
	n = M;
	int cnt = N;
	for (int d = 1; d <= M; d++) {
		cnt -= range[d].size();
		for (int idx : range[d]) {
			add(l[idx], 1);
			if (r[idx] + 1 <= n) add(r[idx] + 1, -1);
		}
		int ans = cnt;
		for (int i = d; i <= M; i += d) {
			ans += sum(i);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 9216
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,K = II()
S = str(input())

S = S[:K-1] + S[K-1].lower() + S[K:]

print(S)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int pre[300500];
void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < n; i++) {
		pre[i + 1] = pre[i] + (s[i] == 'W');
	}
	int res = INT_MAX;
	for (int i = 1; i <= n; i++) {
		res = min(res, pre[i - 1] + n - i - pre[n] + pre[i]);
	}
	cout << res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 4920
import java.io.*;
import java.util.Scanner;

public class Main{
	public static void main(String[] arsg) throws IOException{
		Scanner scan = new Scanner(System.in);
		
		int[] x = new int[6];
		
		for(int i = 0;i<6;i++){
			x[i] = scan.nextInt();
		}
		int y = scan.nextInt();
		
		for(int i = 0;i<y;i++){
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(b==x[1]&&a==x[0]||
			   b==x[0]&&a==x[4]||
			   b==x[4]&&a==x[5]||
			   b==x[5]&&a==x[1]){
			   	System.out.println(x[2]);
			}
			else if(b==x[0]&&a==x[2]||
			        b==x[3]&&a==x[0]||
			        b==x[5]&&a==x[3]||
			         b==x[2]&&a==x[5]){
			   	System.out.println(x[1]);
			}			
			else if(b==x[1]&&a==x[3]||
			        b==x[3]&&a==x[4]||
			        b==x[4]&&a==x[2]||
			        b==x[2]&&a==x[1]){
			   	System.out.println(x[0]);
			}
			else if(b==x[0]&&a==x[1]||
			        b==x[1]&&a==x[5]||
			        b==x[5]&&a==x[4]||
			        b==x[4]&&a==x[0]){
			   	System.out.println(x[3]);
			}				
			else if(b==x[0]&&a==x[3]||
			        b==x[2]&&a==x[0]||
			        b==x[5]&&a==x[2]||
			        b==x[3]&&a==x[5]){
			   	System.out.println(x[4]);
			}			
			else if(b==x[1]&&a==x[2]||
			        b==x[2]&&a==x[4]||
			        b==x[4]&&a==x[3]||
			        b==x[3]&&a==x[1]){
			   	System.out.println(x[5]);
			}					
		}
	}
}
				

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

int main() {
  int N; cin >> N;
  map<int, int> A;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (A.count(a)) A[a]++;
    else A[a] = 1;
  }
  bool flag = true;
  int parity = 0;
  if (N % 2 == 1) {
    if (A.count(0)) A[0]++;
    parity = 1;
  }
  for (int i = 0; i < N; i++) {
    if (i % 2 == parity) {
      if (A.count(i)) flag = false;
    }
    else {
      if (!A.count(i)) flag = false;
      if (A.count(i)) if (A[i] != 2) flag = false;
    }
  }
  if (flag) {
    long long ans = 1;
    for (int i = 0; i < N/2; i++) {
      ans = (ans * 2) % 1000000007;
    }
    cout << ans << endl;
  }
  else cout << 0 << endl;
}


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

int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int c = 0;
  for(int i = L; i <= R; i++){
    if(i % d == 0){
      c++;
    }
  }
  cout << c << endl;
}

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

using namespace std;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	string S; cin >> S;
	REP(i,4) cout << S[i];
	cout << " ";
	FOR(i,4,12) cout << S[i];
	cout << endl;


	return 0;

}


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

#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, 1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << "Line " << __LINE__ <<": " << x << nl
#define pb push_back
#define nl "\n"
#define sp " "

#define _ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define file() freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout)

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

const int N = 1e5+5;

int tc = 1;

int n, ara[N], cnt;

char c;

int main(){_

   	//file();

   	//cin >> tc;

    while(tc--){

    	cin >> c;

    	if(c >=  'a' and c <= 'z')
    		cout << 'a' << nl;
    	else
    		cout << 'A' << nl;
    	
    }
    

    return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n;
	cin>>n;
	ll m = sqrt(n);
	cout<<m*m<<endl;
	return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int res = 0;
	for (int i = 0; i < n; i++) {
		res += p[i];
	}
	res -= p[n-1] / 2;
	cout << res << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n = int(input())
a = [int(i) for i in readline().split()]
m = map(int,read().split())

g = [[] for _ in range(n)]
for i,j in zip(m,m):
    g[i-1].append(j-1)
    g[j-1].append(i-1)

INF = 10**9

q = [~0,0]
dp = [INF]*n
ans = [0]*n
val = 0
idx = [-1]*n
old = [-1]*n
parent = [-1]*n

ss = 0
from bisect import bisect_left
while q:
    v = q.pop()
    if v >= 0:
        iv = idx[v] = bisect_left(dp,a[v])
        x = old[v] = dp[idx[v]]
        if x == INF: val += 1
        ans[v] = val

        dp[iv] = a[v]
        for c in g[v]:
            if c != parent[v]:
                parent[c] = v            
                q.append(~c)
                q.append(c)
    else:
        v = ~v
        x = dp[idx[v]] = old[v]
        if x == INF: val -= 1
    

print(*ans,sep="\n")



Measured memory_bytes: 78880
H, W = [int(i) for i in input().split()]
A = [[]] * H
for i in range(H):
    A[i] = [int(i) for i in input().split()]

ans = []
x = -1
for i in range(H):
    x = x * (-1)
    l, r, d = (0, W, 1) if i % 2 == 0 else (W-1, -1, -1)
    for j in range(l, r, d):
        #print("i,j=",i, j)
        if A[i][j] % 2 == 0:
            continue
        if x == 1 and i == H - 1 and j == W - 1:
            continue
        if x == -1 and i == H - 1 and j == 0:
            continue
        
        if not(j + x < 0 or j + x >= W):
            A[i][j] = A[i][j] - 1
            A[i][j + x] = A[i][j + x] + 1
            ans.append((i, j, i, j+x))
        else :
            A[i][j] = A[i][j] - 1;
            A[i+1][j] = A[i+1][j] + 1
            ans.append((i, j, i+1, j));


print (len(ans))
for y, x, b, a in ans:
    print (y+1, x+1, b+1, a+1)
        


Measured memory_bytes: 22704
#include<stdio.h>
#include<string.h>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int ma=a+b,mb=a+c,mc=b+c;
	int min=ma;
	if(min>mb)
		min=mb;
	if(min>mc)
		min=mc;
	printf("%d\n",min);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int t = 0;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if (S == "P" || S == "G" || S == "W")
      continue;
    
    if (S == "Y") {
      t = 1;
      break;
    }
  }
  
  if (t)
    cout << "Four" << endl;
  if (t == 0)
    cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  if(a%2==0||b%2==0||c%2==0) {
    cout << 0 << endl;
  }
  else {
    cout << min({a*b,b*c,c*a}) << endl;
  }
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N,T = sc.nextInt()
  val a = List.fill(N,2)(sc.nextInt()) filter (_(1)<=T)
  println(
    if(a==Nil) "TLE"
    else a.sortBy(_.head).head.head
  )
}

Measured memory_bytes: 25664
#include<stdio.h>

signed main(){
int a,b,c,d,e;
 scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);

 if(a==0){
 printf("1\n");
 }
 
  if(b==0){
 printf("2\n");
 }
  
  if(c==0){
 printf("3\n");
 }
 
  
  if(d==0){
 printf("4\n");
 } 
 
  if(e==0){
 printf("5\n");
 }
  
  
  return 0;
 }
  
  
  
  
  
  


Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

int main(){
	bool ok[30];
	memset(ok, false, sizeof(ok));
	int num;

	rep(i, 28){
		cin >> num;
		ok[--num] = true;
	}
	rep(i, 30){
		if(!ok[i]) {
			cout << i + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll N, X;
  cin >> N >> X;
  vector<ll> ds(N + 1);
  ds[0] = 0;
  int x;
  for(int i = 0; i < N; ++i) {
    cin >> x;
    ds[i + 1] = ds[i] + x;
  }
  ll ans = 0;
  for(int i = 0; i <= N; ++i) {
    if(ds[i] <= X) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {
    public static void main(String [] args) {
        Reader in = new Reader ();
        Writer out = new Writer ();
        int n = in.nextInt();
        ArrayList <Integer> a = new ArrayList <> ();
        for(int i = 1; i <= n+n; i++) {
            a.add(in.nextInt());
        }
        Collections.sort(a);
        long ans = 0;
        for(int i = 0; i < n+n; i += 2) {
            ans += Math.min(a.get(i), a.get(i+1));
        }
        System.out.println(ans);
    }
    static class Reader {
        private StringTokenizer a;
        private BufferedReader b;
        Reader () {
            a = null;
            b = new BufferedReader (new InputStreamReader (System.in));
        }
        public String next () {
            while(a == null || !a.hasMoreTokens()) {
                try {
                    a = new StringTokenizer (b.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return a.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(this.next());
        }
        public long nextLong () {
            return Long.parseLong(this.next());
        }
        public double nextDouble () {
            return Double.parseDouble(this.next());
        }
        public String nextLine() {
            try {
                return b.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }
    }
    static class Writer {
        private PrintWriter a;
        private StringBuffer b;
        Writer () {
            a = new PrintWriter (System.out);
            b = new StringBuffer ("");
        }
        public void write (Object s) {
            b.append(s);
        }
        public void writeln(Object s) {
            b.append(s).append('\n');
        }
        public void flush () {
            a.print(b);
            a.flush();
            a.close();
        }
    }
    static class Pair implements Comparator <Pair> {
        int first;
        int second;
        Pair  (int a, int b) {
            this.first = a;
            this.second = b;
        }
        Pair (Pair a) {
            this.first = a.first;
            this.second = a.second;
        }
        Pair () {}
        public String toString () {
            return "[" + first + ", " + second + "]";
        }
        public int compare (Pair a, Pair b) {
            if(a.first == b.first) {
                return a.second - b.second;
            } else {
                return a.first - b.first;
            }
        }
    }
}


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

namespace AtCoderCS
{
    class MainClass
    {
		public static void Main(string[] args)
		{
			var nums = Console.ReadLine().Split().Select(int.Parse).ToList();

			int max = nums.Max();
			int min = nums.Min();

			Console.WriteLine(max - min);
		}
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int x,n,p[100],min=1000;
    cin>>x>>n;
    int minn=x;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p,p+n);
    for(int i=0;i<=101;i++){
        for(int j=0;j<n;j++){
            if(p[j]==i)break;
            else if(j==n-1&&min>abs(x-i)){
                min=abs(x-i);
                minn=i;
            }
        }
    }
    cout<<minn<<"\n";
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 10e9 + 7;
typedef long long ll;

int main(){
	int H, W;
	cin >> H >> W;
	vector<vector<char>> P(H, vector<char>(W));
	rep(i, H){
		rep(j, W){
			cin >> P.at(i).at(j);
		}
	}
	rep(i, H){
		rep(k, 2){
			rep(j, W){
				cout << P.at(i).at(j);
				if(j == W - 1)cout << endl;
			}
		}
	}
}

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

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;

    bool res = false;
    for(int i=0;i<s.size();i++){
        string tmp = s.substr(i) + s.substr(0, i);
        if(tmp == t){
            res = true;
            break;
        }
    }
    cout << (res?"Yes":"No") << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    rep(i, N) cin >> H.at(i);

    vector<vector<int>> route(N, vector<int>(1, 0));
    rep(i, M) {
        int st, en;
        cin >> st >> en;
        if(route.at(st - 1).at(0) == 0) {
            route.at(st - 1).at(0) = en;
        } else {
            route.at(st - 1).push_back(en);
        }
        if(route.at(en - 1).at(0) == 0) {
            route.at(en - 1).at(0) = st;
        } else {
            route.at(en - 1).push_back(st);
        }
    }

    // rep(i, N) {
    //     for(auto r : route.at(i)) {
    //         cout << "i = " << i + 1 << " " << "r = " << r + 1 << endl;
    //     }
    // }

    int cnt = 0;
    rep(i, N) {
        int he = H.at(i);
        bool flg = true;
        rep(j, route.at(i).size()) {
            int r = route.at(i).at(j);
            if(r == 0) break;
            if(he <= H.at(r - 1)) {
                flg = false;
                break;
            }
        }
        if(flg) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 9604
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;


bool cmpf(pair<lli,lli> left,pair<lli,lli> right){
	return left.first<right.first;
}


int main() {
	lli n,m,ans=0;
	cin>>n >>m;
	vector<pair<lli,lli>> vec(n);
	
	rep0(i,n)cin >> vec[i].first >>vec[i].second;
	
	sort(all(vec),cmpf);
	vec.emplace_back(-1,-1);
	priority_queue<lli, vector<lli>> que;
	lli num=0;
	rep1(i,m){
		while(vec[num].first!=-1&&vec[num].first==i){
			que.push(vec[num].second);
			num++;
		}
		if(!que.empty()){
			ans+=que.top();
			que.pop();
		}
	}
	cout <<ans;
}


Measured memory_bytes: 5092
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 1e6 + 1;
int fr[N] , n , a[N];
vector<int> dv[N];
int gcd(int a , int b){
	if(b == 0)return a;
	return gcd(b , a%b);
}
int main(){
	for (int i = 2; i < N; ++i){
		if(dv[i].size())continue;
		for (int j = i; j < N; j += i){
			dv[j].pb(i);
		}
	}
	scanf("%d",&n);
	bool f = 0;
	for (int i = 0; i < n; ++i){
		scanf("%d",a+i);
		for(auto x : dv[a[i]])if(fr[x]++) f = 1;
		
	}
	if(!f)return puts("pairwise coprime") , 0;
	int g = a[0];
	for (int i = 1; i < n; ++i){
		g = gcd(g , a[i]);
	}
	puts(g == 1?"setwise coprime":"not coprime");



	
	
}	

Measured memory_bytes: 66868
#
# File    : C.rb
# Author  : Kazune Takahashi
# Created : 2018-7-23 16:34:50
# Powered by Visual Studio Code
#

a = gets.chomp.split(" ").map{|i| i.to_i}
m = a.max
sum = a.inject(:+)
x = nil
if (3 * m - sum) % 2 == 0
  x = m
else
  x = m + 1
end

puts (3 * x - sum) / 2



Measured memory_bytes: 1916
#include<iostream>
using namespace std;
int main(){
  int a[101],b[101];
  int i,cnt;
  for(i=0;i<4;i++)cin>>a[i];
  for(i=0;i<101;i++)b[i]=0;
 for(i=a[0];i<a[1];i++){
   b[i]=1;
 }
  for(i=a[2];i<a[3];i++){
   if(b[i]==1){
     cnt++;
   }
 }
  cout<<cnt;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

bool isPrime(int x) {
    bool flag = true;
    for (int i = 2; i < sqrt(x); i++) if (!(x % i)) flag = false;

    return flag;
}


int main() {
    int x;
    cin >> x;
    while (!isPrime(x)) x++;
    cout << x << endl;
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {

}

int main() {
  int n;
  cin >> n;
  unordered_set<string> S;
  string s;
  rep(i,n) {
    cin >>s;
    S.insert(s);
  }
  cout << S.size() << endl;
  return 0;
}


Measured memory_bytes: 17704
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

void solve()
{
    ll n,m;
    cin>>n>>m;
    vector<ll>x(n);
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        sum+=x[i];
    }

    sort(x.rbegin(), x.rend());
    ll de = m*4;
    ll lol = (sum+de-1)/de;
    ll i=0;
    
    for(i=0;i<m;i++)
    {
        if(x[i]<lol)
        {
            break;
        }
    }
    if(i==m)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>

const int Max = 1000001;

int dishes[31];
bool dish[Max];
bool isPrime[Max];

int main(){

	for (int i = 2; i < Max; i++)isPrime[i] = true;
	for (int i = 2; i < std::sqrt(Max); i++){
		if (isPrime[i]){
			for (int j = i * 2; j < Max; j += i)isPrime[j] = false;
		}
	}

	int n, x;
	while (std::cin >> n, n){

		std::cin >> x;
		memset(dish, 0, sizeof(dish));

		for (int i = 0; i < n; i++){
			std::cin >> dishes[i];
		}

		dish[0] = true;
		for (int i = 0; i < x; i++){
			if (dish[i]){
				for (int j = 0; j < n; j++){
					if (i + dishes[j] <= Max)dish[i + dishes[j]] = true;
				}
			}
		}

		for (int i = x; i >= 0; i--){
			if (dish[i] && isPrime[i]){
				std::cout << i << std::endl;
				break;
			}
			if (i == 0)std::cout << "NA" << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3124
from math import gcd
from collections import defaultdict

n = int(input())
a, b = [], []
for i in range(n):
    data = list(map(int, input().split()))
    a.append(data[0])
    b.append(data[1])

d = defaultdict(lambda: [0, 0])
zeros = 0

for i in range(n):
    if a[i] * b[i] != 0:
        g = gcd(a[i], b[i])
        a[i] //= g
        b[i] //= g
    if a[i]*b[i] > 0:
        d[(abs(a[i]), abs(b[i]))][0] += 1
    elif a[i]*b[i] < 0:
        d[(abs(b[i]), abs(a[i]))][1] += 1
    elif a[i] == 0 and b[i] != 0:
        d[(0, 1)][0] += 1
    elif b[i] == 0 and a[i] != 0:
        d[(0, 1)][1] += 1
    elif a[i] == b[i] == 0:
        zeros += 1

mod = 1000000007
cnt = 1
for pair in d.values():
    cnt *= pow(2, pair[0], mod) + pow(2, pair[1], mod) - 1
    cnt %= mod
cnt += zeros - 1
cnt %= mod
print(cnt)

Measured memory_bytes: 71148
#include <iostream>
#include <iomanip>

void call(int n) {
	int i = 1;
CHECK_NUM:
	int x = i;
	if (x % 3 == 0) {
		std::cout << " " << i;
		goto END_CHECK_NUM;
	}
INCLUDE3:
	if (x % 10 == 3) {
		std:: cout << " " << i;
		goto END_CHECK_NUM;
	}
	x /= 10;
	if (x) goto INCLUDE3;
END_CHECK_NUM:
	if (++i <= n) goto CHECK_NUM;

	std::cout << std::endl;
}

void call2(int n) {
	for (int i = 1; i <= n; ++i) {
		int x = i;
		if (x % 3 == 0) {
			std::cout << " " << i;
			continue;
		}
		do {
		if (x % 10 == 3) {
			std::cout << " " << i;
			break;
		}
		x /= 10;
		} while (x != 0);
	}
	std::cout << std::endl;
}

int main()
{
	int n;
	std::cin >> n;
	call2(n);
	return 0;
}




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

using namespace std;

int main(){
	string s, ans;
	cin >> s;

	ans.clear();
	for (int i = 0; i < s.size(); i++){
		switch(s[i]){
		case '0':
			ans += "0";
			break;
		case '1':
			ans += "1";
			break;
		case 'B':
			if (ans.size() != 0){
				ans.erase(ans.size() - 1);
			}
			break;
		}
	}

	cout << ans << endl;
	return 0;
}


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

int main() {
        string strin;
        cin >> strin;
        if (strin.length() == 3) {
            char chTmp = strin.at(0);
            strin.at(0) = strin.at(2);
            strin.at(2) = chTmp;
        }
        cout << strin;
        return 0;
    }

Measured memory_bytes: 256
N = int(input())

count = [0] * 201
count[105] = 1
for i in range(105, 201):
    if i % 2 == 1:
        num = 0
        for n in range(1, i+1):
            if i % n == 0:
                num += 1
        if num == 8:
            count[i] = count[i-1]+1
        else:
            count[i] = count[i-1]
    else:
        count[i] = count[i-1]

print(count[N])

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

using namespace std;

#define RPT(n) for (size_t i = 0; i < n; i++)

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

    RPT(S.size()) {
        S[i] = (S[i] - 'A' + N) % 26 + 'A';
    }

    cout << S << endl;

    return 0;
}


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

int main(){
  	int x,y;
  	cin >> x >> y;
  	cout << x + y/2 << endl;
    return 0;
}

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

int main()
{
    ll n,m;
    cin>>n>>m;
    /*vector<vector<bool> > v(n,vector<bool>(m,0));
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            for(ll k=i-1;k<=(i+1);k++)
            {
                for(ll l=j-1;l<=j+1;l++)
                {
                    if(k>=0 && k<n && l>=0 && l<m)
                    {
                        v[k][l]=!v[k][l];
                    }
                }
            }
        }
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            cout<<v[i][j];
        }
        cout<<endl;
    }*/
    ll ans=(n-2)*(m-2);
    cout<<abs(ans)<<endl;
    return 0;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, string).chars().collect::<vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, string).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        n: usize
    }

    let mut queue: VecDeque<i64> = VecDeque::new();
    for i in 1..10 {
        queue.push_back(i);
    }
    for _ in 0..n-1 {
        let x = match queue.pop_front() {
            Some(x) => x,
            _ => 0
        };
        let nx = x * 10 + x % 10;
        if x % 10 != 0 {
            queue.push_back(nx - 1);
        }
        queue.push_back(nx);
        if x % 10 != 9 {
            queue.push_back(nx + 1);
        }
    }

    println!("{}", queue.pop_front().unwrap());
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL dp[262262]; // 2 の 18乗 = 262144 より大きければ良いはず.

int main(){

    // 1. 入力情報取得.
    int M;
    LL K;
    scanf("%d %lld", &M, &K);
    
    // 2. 数列作成(K >= 2 の M乗).
    int l = 1 << M; // 数列の長さ.
    // sample_02 で, WA となったので, if文 を 修正.
    // if(K >= l){
    if(K >= l || (M == 1 && K == 1)){
        printf("%d\n", -1);
        return 0;
    }
    
    // 3. 数列作成(K < 2 の M乗).
    int base = l - 1, counter = 0;
    // 3-1. K == 0
    // ex.
    // M = 2, K = 0
    // 0 0 -> 1 0 0 1 -> 2 1 0 0 1 2 -> 3 2 1 0 0 1 2 3 とすれば良さそう.
    if(K == 0){
        dp[base] = K, dp[base + 1] = K;
        for(int i = 0; i < l; i++) if(i != K) counter++, dp[base - counter] = dp[base + 1 + counter] = i;
    }
    
    // 3-2. K > 0
    // M = 2, K = 1
    // 1 -> 0 1 0 -> 2 0 1 0 2 -> 3 2 0 1 0 2 3 -> 3 2 0 1 0 2 3 1 とすれば良さそう.
    // 
    // M = 2, K = 2
    // 2 -> 0 2 0 -> 1 0 2 0 1 -> 3 1 0 2 0 1 3 -> 3 1 0 2 0 1 3 2 とすれば良さそう.
    // 
    // M = 2, K = 3
    // 3 -> 0 3 0 -> 1 0 3 0 1 -> 2 1 0 3 0 1 2 -> 2 1 0 3 0 1 2 3 とすれば良さそう.
    if(K > 0){
        dp[base] = K, dp[2 * base + 1] = K;
        for(int i = 0; i < l; i++) if(i != K) counter++, dp[base - counter] = dp[base + counter] = i;
    }
    
    // 4. 後処理.
    for(int i = 0; i < 2 * l; i++) printf("%lld ", dp[i]);
    return 0;

}

Measured memory_bytes: 3840
N = int(input())
xy = list()
ans = 0
for i in range(N):
  xy.append(list(map(int, input().split())))
for j in range(N):
  for k in range(j+1,N):
    ans += ((xy[k][0] - xy[j][0]) ** 2 + (xy[k][1] - xy[j][1]) ** 2) ** 0.5
    
print((ans / (N * (N-1) // 2)) * (N-1))

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

typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

const int MAX = 3000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int x,y;
    cin >> x >> y;
    if((x+y)%3 != 0) { 
        cout << 0 << endl;
        return 0;
    }
    int m = (2*x)/3 - y/3;
    int n = x-2*m;
    COMinit();
    cout << COM(n+m,n) << endl;;

}

Measured memory_bytes: 73904
#include<iostream>
using namespace std;
int main()
{
	int a, b, c, d, c2, irekae, i, n;
	a = 0;
	b = 0;
	c = 0;
	d = 0;
	c2 = 0;
	cin >> n;
	for( i = 0; i < n; i++)
	{
		cin >> a >> b >> c;
	if( a > c)
	{
		irekae = a;
		a = c;
		c = irekae;
	}
	if ( b > c )
	{
		irekae = b;
		b = c;
		c = irekae;
	}
		d = (a * a) + (b * b);
		c2 = (c * c); 
		if( d == c2 )
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

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

typedef long long ll;
const long long mod = 1e9 + 7;
const long long maxn = 1e6 + 5;

int main()
{
	ll n, sum = 0;
	scanf("%lld",&n);
	for (ll i = 1; i <= n; i++)
	{
		if (i % 3 == 0 || i % 5 == 0)
		{
			continue;
		}
		else
		{
			sum += i;
		}
	}
	printf("%lld\n",sum);
	return 0;
}
 


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

#define ll long long
#define ld long double
#define pi 3.14159265359
int main(){
    int N; cin >> N;
    vector<ll> A(N),sum(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum.at(A.at(i) - 1)++;
    }
    vector<ll> combi(N);
    ll combisum = 0;
    for (int i = 0; i < N; i++) {
        combi.at(i) = max((sum.at(i) * (sum.at(i) - 1)) / 2, (ll)0);
        combisum += combi.at(i);
    }
    ll ans;
    for (int i = 0; i < N; i++) {
        ans = combisum - combi.at(A.at(i) - 1) + max(((sum.at(A.at(i) - 1) - 1) * (sum.at(A.at(i) - 1) - 2)) / 2, (ll)0);
        cout << ans << endl;
    }
}


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

#define INF 1000000000000


int main(){

 ll n; cin>> n;
 ll ans=0;
 rep(i,n+1){
   if(i%3!=0 && i%5!=0){
     ans+=i;
   }
 }
 cout<<ans;

}


Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int r;
    cin >> r;
    cout << 3 * r * r  << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;

int main(){
	string S;
	bool b = false;
	cin >> S;

	int y, m, d;

	y = atoi(S.substr(0, 4).c_str());
	m = atoi(S.substr(5, 6).c_str());
	d = atoi(S.substr(8, 9).c_str());

	if (y < 2019)
		b = true;
	else if (y == 2019){
		if (m < 4)
			b = true;
		else if (m == 4){
			if (d <= 30)
				b = true;
		}

	}

	if (b)
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;


	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n;
	cin >> n;
	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		ans[x - 1] = i;
	}
	for (int i : ans) cout << i + 1 << " ";
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 1664