akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;



long long int N,M,res=0;

long double a,b,c;

int main()
{
    cout << fixed << setprecision(18);
   cin>>a>>b>>c;
   IFYes(sqrt(a)+sqrt(b)+1e-14<sqrt(c));
   
    
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

import static java.lang.Math.*;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final long x = abs(scanner.nextLong());
        final long k = abs(scanner.nextLong());
        final long d = abs(scanner.nextLong());

        if (x / d >= k) {
            System.out.println(x - d * k);
            return;
        }

        final long k1 = x / d;
        // k1 か k1+1回移動するのが最適
        // k1回移動して 0 <= t < d
        if (k1 % 2 == k % 2) {
            System.out.println(abs(x - d * k1));
        } else {
            if (k1 <= k - 1) {
                System.out.println(min(abs(x - d * (k1 + 1)), abs(x - d * (k1 - 1))));
            } else {
                System.out.println(abs(x - d * (k1 - 1)));
            }
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

Measured memory_bytes: 32844
import scala.io.StdIn

object Main extends App {

  val Array(h, w) =  StdIn.readLine().split(" ").map(_.toInt)
  val pict = (0 until h).map { _ => StdIn.readLine()}.toList
  val pict2 = pict.flatMap(s => List(s,s ))
  
  pict2.foreach(println)
  
}


Measured memory_bytes: 26544
#include <iostream>
#include <string>
using namespace std;
int main() {
	string str;
        cin >> str;
        int a = 0;
        int b = 0;
        int c = 0;
        for(int i = 0; i < 3; i++){
             if(str[i] == 'a'){a +=1;}else if(str[i] == 'b'){b +=1;}else if(str[i] == 'c'){c +=1;}
        }

        if(a == c && b == c){
          printf("Yes\n");
        }else{printf("No\n");
        }
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define F first
#define re return
#define S second
#define ll long long
#define f(i) return cout<<i<<"\n",0;
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define lp(i,a,b) for (int i=(a);i<=(int)(b);++i)
#define lp2(i,a,b) for (int i=(a);i>=(b);--i)
#define clr(c,x) memset(c,x,sizeof(c))
#define allr(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end()
const int N=2e5+5,mod=(int)1e9+7;
vi a,b,c;
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int l,nodes=0;
    cin>>l;

    while((1<<nodes)<=l) nodes++;
    lp(i,1,nodes-1)
    {
        a.pb(i);
        b.pb(i+1);
        c.pb(0);
        a.pb(i);
        b.pb(i+1);
        c.pb((1<<(i-1)));
    }
    for (int i=nodes-1; i>=1; --i)
    {
        if ((1<<(nodes-1))<=l-(1<<(i-1)))
        {
            a.pb(i);
            b.pb(nodes);
            l-=(1<<(i-1));
            c.pb(l);
        }
    }
    cout<<nodes<<" "<<a.size()<<"\n";
    lp(i,0,a.size()-1) cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> nx(n);
  rep(i, n){
    int a;
    cin >> a;
    nx.at(i) = a - 1;
  }
  vector<bool> flag(n, false);
  flag.at(0) = true;
  int now = 0;
  int co = 0;
  while(1){
    co++;
    now = nx.at(now);
    if(flag.at(now) == true){
      cout << -1 << endl;
      return 0;
    }
    if(now == 1){
      cout << co << endl;
      return 0;
    }
    flag.at(now) = true;
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int A = a+b;
		int B = b+c;
		int C = c+a;

		int [] list = new int [] {A, B, C};
		int min =list[0];

		for (int i = 1; i < list.length; i++) {
			int M = list[i];
			if (M <= min) {
				min = M;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
double f(double k, int p) {
	if (p == 0)return 1;
	else return k*f(k, p - 1);
}
int main() {
	int n;
	while (cin >> n, n) {
		int y; cin >> y;
		double maxv = 0; int maxn;
		for (int i = 1; i <= n; i++) {
			int b, t; double r; cin >> b >> r >> t;
			double v;
			if (t == 1)v = 1 + y*r / 100;
			else v = f(1 + r / 100, y);
			if (v > maxv) { maxv = v; maxn = b; }
		}
		cout << maxn << endl;
	}
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 INF=1001001001;

int main() {
  int x;
  cin>>x;
  for(int i=0;i<=1000;i++){
   if(x>=100*i&&x<=105*i){cout<<1<<endl;return 0;}
  }
  cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int N;
char S[12];
int main(){
  int i;
  N = rd(S);
  if(N%2){
    wt_L("No");
    wt_L('\n');
    return 0;
  }
  for(i=(0);i<(N);i+=(2)){
    if(S[i] != 'h'){
      wt_L("No");
      wt_L('\n');
      return 0;
    }
  }
  for(i=(1);i<(N);i+=(2)){
    if(S[i] != 'i'){
      wt_L("No");
      wt_L('\n');
      return 0;
    }
  }
  wt_L("Yes");
  wt_L('\n');
  return 0;
}
// cLay varsion 20200308-1

// --- original code ---
// int N;
// char S[12];
// {
//   rd(S@N);
//   if(N%2) wt("No"), return 0;
//   rep(i,0,N,2) if(S[i] != 'h') wt("No"), return 0;
//   rep(i,1,N,2) if(S[i] != 'i') wt("No"), return 0;
//   wt("Yes");
// }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String divide[] = { "dream", "dreamer", "erase", "eraser" };
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		//すべての文字列を左右反転
		StringBuffer sb = new StringBuffer(s);
		s = sb.reverse().toString();
		//		System.out.println(s);
		for (int i = 0; i < 4; i++) {
			sb = new StringBuffer(divide[i]);
			divide[i] = sb.reverse().toString();
			//			System.out.println(divide[i]);
		}

		//端から切っていく
		boolean flg = true;
		for (int i = 0; i < s.length();) {
			boolean flg2 = false;//4この文字のうち、どれかでdevide出来るか判定
			for (int j = 0; j < 4; j++) {
				String d = divide[j];
//				System.out.println(s.substring(i, i + d.length()));
				if (s.length() >= i + d.length() && s.substring(i, i + d.length()).equals(d)) {//dでdivide出来るか
					flg2 = true;
					i += d.length();//divide出来たらiを進める
				}
			}
			if (!flg2) {//divide出来なかったら
				flg = false;
				break;
			}
		}

		if (flg) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}


Measured memory_bytes: 30840
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;
#define OFFSET (2 * 8000)
bool dp[2][8000][2][2 * OFFSET];

int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;

    vector<int> diff[2];

    diff[1].push_back(0);

    int assigned = 0;
    int key = 0;
    REP(i, s.length()) {
        if (s[i] == 'T') {
            int k = i - assigned;
            diff[key].push_back(k);
            key = (key + 1) % 2;
            assigned = i + 1;
        }
    }

    if (assigned != s.length()) {
        int k = s.length() - assigned;
        diff[key].push_back(k);
    }

    /*
    REP(k, 2) {
        REP(i, diff[k].size())
        cout << diff[k][i] << endl;
        cout << endl;
    }
    */

    // (x,y) s_length, dir, pos

    dp[0][0][0][diff[0][0] + OFFSET] = true;
    dp[1][0][0][0 + OFFSET] = true;
    dp[1][0][1][0 + OFFSET] = true;

#define GET(vec, pos) (0 <= pos && pos < 2 * OFFSET && vec[pos])

    for (int i = 0; i < 2; i++) {
        for (int j = 1; j < diff[i].size(); j++) {
            for (int k = 0; k < 2; k++) {
                for (int l = 0; l < 2 * OFFSET; l++) {
                    dp[i][j][k][l] = GET(dp[i][j - 1][k], l - diff[i][j]) || GET(dp[i][j - 1][k], l + diff[i][j]);
                }
            }
        }
    }

    bool x_ok = GET(dp[0][diff[0].size() - 1][0], x + OFFSET) || GET(dp[0][diff[0].size() - 1][1], x + OFFSET);
    bool y_ok = GET(dp[1][diff[1].size() - 1][0], y + OFFSET) || GET(dp[1][diff[1].size() - 1][1], y + OFFSET);

    cout << (x_ok && y_ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 499968
#include<cstdio>
int N,M,A[310][310],fr[310],cnt[310];
bool del[310];
int main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++)
		for(int j=0;j<M;j++)scanf("%d",A[i]+j);
	int m=N;
	for(int t=M;t--;){
		int mc=0,mi;
		for(int i=1;i<=M;i++)cnt[i]=0;
		for(int i=0;i<N;i++){
			while(del[A[i][fr[i]]])++fr[i];
			if(++cnt[A[i][fr[i]]]>mc)mc=cnt[mi=A[i][fr[i]]];
		}
		if(mc<m)m=mc;
		del[mi]=1;
	}
	printf("%d\n",m);
}

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

using namespace std;

int main()
{
  int a,b;
  cin>>a>>b;
  int x=a+b;
  int y=2*a-1;
  int z=2*b-1;
  int h=max({x,y,z});
  cout<<h<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int main(){
  itn n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<itn,int> mp;
  itn ans=0;
  rep(i,n) mp[a[i]]=mp[a[i]-1]+1;
  for(auto v:mp) chmax(ans,v.second);
  cout << n-ans << endl;
}

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

int main(){

int i,j,h,temp;
int m[10];



//入力
for(i=0; i<10; i++){
   cin >> h;

   if(h >= 0 and h <= 10000){
       m[i]=h;
   }else{
   i--;
   }
}



//ソート
    for (i = 0; i < 9; i++) {
        for (j = 9; j > i; j--) {
            if (m[j - 1] > m[j]) {  
                temp = m[j];  
                m[j] = m[j - 1];
                m[j - 1] = temp;
            }
        }
    }
    
    
//出力
for (i = 9; i > 6; i--) {
   cout << m[i] << "\n";
}

    return 0;
}

Measured memory_bytes: 1160
n=int(input())
def f(n,r):
    return n==r|(n-r)
s=list(map(int,list(input())))
b=[]
for i in range(n-1):b.append(abs(s[i]-s[i+1]))
if (0 in b and len(set(b))==2) or len(set(b))==1:
    ans=0
    anss=0
    for i in range(n-1):
        if b[i]:
            anss=b[i]
            ans+=f(n-2,i)
    if ans%2==0:
        print(0)
    else:
        print(anss)
    quit()
ans=0
for i in range(n-1):
    if b[i]%2==1:
        anss=b[i]
        ans+=f(n-2,i)
if ans%2==0:
    print(0)
else:
    print(1)
    

Measured memory_bytes: 32096
N, K = map(int, input().split())
A = list(map(int, input().split()))


x0, x1 = 0, 10**9
while x0+1 < x1:
    x = (x0+x1)//2
    s = sum((a-1)//x for a in A)
    
    if s > K:
        x0 = x
    else:
        x1 = x

print(x1)

    
    


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

int main()
{
    string n,m;

    cin>>n>>m;

    sort(n.begin(), n.end());
    sort(m.begin(), m.end(), greater<int>());


    if(n < m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;




}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <string>
#include <queue>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;
typedef long long ll;

int main(){
	//freopen("test.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	vector<P> t(n);
	rep(i, n) cin >> t[i].X >> t[i].Y;
	sort(all(t));

	rep(i, m){
		int lx, by, rx, ty;
		cin >> lx >> by >> rx >> ty;
		vector<P>::iterator left, right;
		left = lower_bound(all(t), MP(lx, -1<<30));
		right = lower_bound(all(t), MP(rx, 1<<30));
		int cnt = 0;
		for(; left != right; left++){
			if(left->Y >= by && left->Y <= ty) cnt++;
		}
		cout << cnt << endl;
	}


	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
            c++;
        }
    }
    cout<<c<<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++)
typedef pair<int,int> P;
typedef long long ll;

int kai(int x) {
    int total = 1;
    for(; x > 0; x--) {
        total *= x;
    }
    
    return total;
}

int main() {
    int n;
    cin >> n;
    
    vector<int> p(n), q(n);
    rep(i,n) {
        cin >> p[i];
    }
    rep(i,n) {
        cin >> q[i];
    }
    
    vector<int> all(n);
    rep(i,n) {
        all[i] = i+1;
    }
    
    map<vector<int>,int> m;
    do {
        m[all] = (int)m.size();
    }while(next_permutation(all.begin(), all.end()));
    
    
    cout << abs(m[p] - m[q]) << endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 8616
n,x=map(int,input().split())
a=sorted([int(i) for i in input().split()])
cnt=0
for j in range(n):
    if x>=a[j]:
        if j!=n-1:
            x-=a[j]
            cnt+=1 
        elif x==a[j]:
            x-=a[j]
            cnt+=1
    else :
        break
print(cnt)

Measured memory_bytes: 3060
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

count = 0
for i in range(N):
  A = list(map(int, input().split()))
  val = sum([a * b for a, b in zip(A, B)]) + C
  if val > 0:
    count += 1
print(count)

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


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;



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

	int r = 0;
	while (true) {
		if ((1 << (r + 1)) <= l) {
			r++;
		}
		else {
			break;
		}
	}


	int n = r+1;
	
	
	set<pair<int,int>> path;

	vector<pair<int, int>>toGoalPath;
	{
		int l_tmp = l;
		for (int i = n - 1;i > 0;i--) {
			if (l_tmp - (1 << (i - 1)) >= (1 << r)) {
				toGoalPath.emplace_back(make_pair(i, l_tmp - (1 << (i - 1))));
				l_tmp -= (1 << (i - 1));

			}
		}
	}

	int m = 2 * (n - 1) + toGoalPath.size();
	cout << n << " " <<m<< endl;
	for (int i = 1; i <n ;i++) {
		cout << i << " " << i+1 << " " << 0 << endl;
		cout << i << " " << i + 1 << " " << (1 <<(i-1)) << endl;
	}
	
	for (auto it = toGoalPath.begin(); it != toGoalPath.end(); it++) {
		cout << it->first << " " << n << " " << it->second << endl;
		
	}
	
}
	


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=2e5+5;
int n,m,top,a[N],fst[N],lst[N],nxt[N],vis[N],s[N];long long k;
int main(){
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(!fst[a[i]])fst[a[i]]=i;
	}
	nxt[n+1]=1;
	for(int i=n;i;--i){
		if(!lst[a[i]])nxt[i]=fst[a[i]]+1;
		else nxt[i]=nxt[lst[a[i]]+1];
		lst[a[i]]=i;
	}
	for(int i=1;!vis[i];i=nxt[i])vis[s[++m]=i]=1;
	memset(vis,0,sizeof(vis));
	for(int i=s[(k-1)%m+1];i<=n;++i)
		if(!vis[a[i]])s[++top]=a[i],vis[a[i]]=1;
		else do vis[s[top--]]=0;while(s[top+1]!=a[i]);
	for(int i=1;i<=top;++i)printf("%d ",s[i]);
	return 0;
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int i = 0, n, x, answer = 0;
    cin >> n >> x;
    vector<int> L;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        L.push_back(a);
    }

    sort(L.begin(), L.end());
    for(; i < n; i++){
        if(x < L[i]) break;
        x -= L[i];
        answer++;
    }
  
    if(x > 0 && i == n) answer--;
    cout << answer << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int N = sc.nextInt();
		int count = 0;
		
		for(int i =1;i<=N;i++) {
			String.valueOf(i);
			if(String.valueOf(i).length()%2==1) {
				count++;
			}
		}
      System.out.println(count);
	}
}

Measured memory_bytes: 32596
// https://atcoder.jp/contests/abc171/tasks/abc171_b

use proconio::input;

fn main() {
    input! {
      n: i32, k: usize,
      mut ps: [i32; n],
    }
    ps.sort();
    let ans: i32 = ps[..k].iter().sum();
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include <stdio.h>
 
int main(int argc, char** argv)
{
    int i, j, k, cnt, n, x, result[1000];
 
    cnt = 0;
     
    memset(result, 0, sizeof(result));
    while (scanf("%d %d", &n, &x) != EOF) {
        int list_cnt = 0;
        
        for (i = 1; i <= n - 2; i++) {
            for (j = i + 1; j <= n - 1; j++) {
                for (k = j + 1; k <= n; k++) {
                    if (i + j + k == x) {
                        list_cnt++;
                    }
                }
            }
        }
 
        result[cnt] = list_cnt;
 
        if (n == 0 && x == 0) {
            break;
        }
        cnt++;
    }
 
    for (i = 0; i < cnt; i++) {
        printf("%d\n", result[i]);
    }
    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int s,w;
    cin >> s >> w;
    bool ans = s <= w;
    cout << (ans? "unsafe" : "safe") << endl;
}

Measured memory_bytes: 3100
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

int main(void)
{
    int a[3];

    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    sort(a, a + 3);
    puts(a[0] == 5 && a[1] == 5 && a[2] == 7 ? "YES" : "NO");

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		scn.nextLine();
		char[] S = scn.nextLine().toCharArray();
		int ans = 1;
		for(int i = 1;i < N;i++) {
			if(S[i] != S[i-1])ans++;
		}
		System.out.println(ans);
	}

}

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

#define N_MAX 500001

struct node{
    int key;
    struct node *right;
    struct node *left;
    struct node *parent;
};

typedef struct node *Node;
Node root = NULL;

void insert(int k){
    Node y = NULL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->right = NULL;
    z->left = NULL;
    while(x != NULL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;

    if(y == NULL){
        root = z;
    }else if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }
}

void ino(Node u){
 
  if(u->left != NULL){
 
    ino(u->left);
  }
 
  printf(" %d",u->key);
 
  if(u->right != NULL){
     
    ino(u->right);
  }
 
}
void pre(Node u){
 
  printf(" %d",u->key);
   
  if(u->left != NULL){
    pre(u->left);
  }
   
  if(u->right != NULL){
    pre(u->right);
  }
   
}

int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            ino(root);
            printf("\n");
            pre(root);
            printf("\n");
        } 
    }
    return 0;
}






Measured memory_bytes: 25236
#include<bits/stdc++.h>
using namespace std;
bool sortby(const pair<long int,long int>&a,const pair<long int,long int>&b)
{
     if(a.second==b.second)
      return (a.first<b.first);

      else
      return a.second < b.second;
}
int main()
{
    int n,i;
      cin>>n;

       vector<pair<long int,long int>>vect;

      for(i=0;i<n;i++)
      {
         long int x,y;
           cin>>x>>y;
            vect.push_back(make_pair(x,y));
      }
      sort(vect.begin(),vect.end(),sortby);

         long long int sum=0,c=0;

         for(i=0;i<vect.size();i++)
         {
            sum+=vect[i].first;

                 if(sum > vect[i].second)
                 {
                    c=1;
                    break;
                 }
         }

            if(c==0)
            cout<<"Yes";

            else
            cout<<"No";
}


Measured memory_bytes: 6256
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    var a = arrayListOf<Int>()
    for (i in 0 until n){
        a.add(readLine()!!.toInt())
    }
    val m_1 = a.max()
    val s = a.filter{ it == m_1 }.size
    if (s >= 2) for (i in 0 until n) println(m_1)
    if (s == 1) {
        val idx = a.indexOf(m_1)
        var b = a.toMutableList()
        b.removeAt(idx)
        val m_2 = b.max()
        for (i in 0 until n) {
            if (i == idx) println(m_2) else println(m_1)
        }
    }
}


Measured memory_bytes: 59376
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;
int main()
{

	ll a, b = 0, c = 0, d = 0;
	ll l;
	string s, t;
	ll n, m, h, w, X;
	
	ll M[10000] = {};
	cin >> n;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> c;
		M[c] = 1;
	}
	for (int i = 1; i <= m; i++)
	{
		if (M[i]==0)
		{
			d++;
		}
	}



	cout << d << endl;

	//cout << sum << endl;
	//cout <<  endl;

	return 0;
}

//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}




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

int main(void) {

    vector<vector<int> > v;
    v.assign(3,vector<int>(3,0));
    rep(i,3){
        rep(j,3){
            int tmp;
            cin >> tmp;
            v[i][j]=tmp;
        }
    }
    int sub;
    rep(i,3){
        sub = min(v[i][0],min(v[i][1],v[i][2]));
        v[i][0] -=sub;
        v[i][1] -=sub;
        v[i][2] -=sub;
    }
    
    rep(i,3){
        sub = min(v[0][i],min(v[1][i],v[2][i]));
        v[0][i] -=sub;
        v[1][i] -=sub;
        v[2][i] -=sub;
    }
    rep(i,3){
        rep(j,3){
            if(v[i][j]!=0)
            {cout << "No" << endl;
            return 0;}
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
using namespace std;
 
#define REP(i,n) for(int i=0; i<(int)(n); i++)
 
template<class T> T getAs(){ T v; std::cin >> v; return v; }
inline int getInt(){ return getAs<int>(); }
 
int main(){
  int n = getInt();
  int m = getInt();
 
  vector<int> a(m);
  vector<int> b(m);
 
  const int MAX = 100000;
  vector<int> dp(n + 1, MAX);
 
  REP(i,m){
    a[i] = getInt() - 1;
    b[i] = getInt() - 1;
  }
 
  dp[0] = 0;
  REP(i,n) if(dp[i] != MAX){
    REP(j,m){
      if(a[j] <= i && i <= b[j]){
        dp[b[j] + 1] = min(dp[b[j] + 1], dp[i] + 1);
      }
    }
  }
 
  // REP(i,n + 1) printf("%d ", dp[i]); puts("");
  if(dp[n] == MAX) puts("Impossible");
  else printf("%d\n", dp[n]);
 
  return 0;
}

Measured memory_bytes: 0
using System;

public class Hello
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
		var n = int.Parse(line[0]);
		var m = int.Parse(line[1]);
		var a = new int[n+1];
		for (int i = 0; i < m; i++)
		{
			 line = Console.ReadLine().Trim().Split(' ');
			var L = int.Parse(line[0]) - 1;
			var r = int.Parse(line[1]) - 1;
			a[L]++;
			a[r + 1]--;
		}
		var count = 0;
		var b = new int[n+1];
		b[0] = a[0];
		if (b[0] == m) count++;
		for (int i = 1; i < n+1; i++)
		{
			b[i] = b[i - 1] + a[i];
			if (b[i] == m) count++;
		}
		Console.WriteLine(count);
	}
}

Measured memory_bytes: 17864
#include <iostream>
using namespace std;
 
int main()
{
    int a, b;
    cin >> a >> b;
    auto s = "a == b";
    if (a > b) {
        s = "a > b";
    } else if (a < b) {
        s = "a < b";
    }
    cout << s << endl;
    return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 1003;

int main(){
  ll N; cin >> N;
  map<ll,ll> mp;
  mp[0] = 1LL; mp[1] = 2LL;
  function<ll(ll)> solve = [&](ll n){
    if(mp.count(n)) return mp[n];
    return mp[n] = (solve(n/2) + solve((n-1)/2) + solve(n/2-1)) % lmod;
  };
  cout << solve(N) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cntAC=0;
        int cntWA=0;
        int cntTLE=0;
        int cntRE=0;
        while(n>0){
            n--;
            String s = sc.next();
            if(s.equals("AC")){
                cntAC++;
            }
            else if(s.equals("WA")){
                cntWA++;
            }
            else if(s.equals("TLE")){
                cntTLE++;
            }
            else if(s.equals("RE")){
                cntRE++;
            }
        }
        System.out.println(String.format("AC x %d",cntAC));
        System.out.println(String.format("WA x %d",cntWA));
        System.out.println(String.format("TLE x %d",cntTLE));
        System.out.println(String.format("RE x %d",cntRE));
    }
}



Measured memory_bytes: 57856
#pragma GCC optimize ("Ofast")
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "div7"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			ifstream cin(_is); \
			ofstream cout(_os);

using namespace std;
	
int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 100005;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-8;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;


int32_t main() {
	FAST;

	int n, m;
	cin >> n >> m;

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

	set<pair<int, int>> s;
	for (int i = 0; i < n; i++) {
		s.emplace(cnt[i], i);
	}

	vector<int> dp(n);
	while (!s.empty()) {
		auto v = *s.begin();

		for (int u: g[v.second]) {
			dp[u] = max(dp[u], dp[v.second] + 1);
			s.erase({cnt[u], u});
			cnt[u]--;
			s.insert({cnt[u], u});
		} 

		s.erase(v);
	}

	cout << *max_element(dp.begin(), dp.end());
}


Measured memory_bytes: 16392
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int) (n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
using namespace std;
bool palindrome(string s){
  string t=s;
  reverse(t.begin(),t.end());
  bool ans=true;
  rep(i,s.size()){
    if(s[i]!=t[i])ans=false;
  }
  return ans;
}
int main(){
  string s;
  cin >> s;
  if(palindrome(s) && palindrome(s.substr(0,(s.size()-1)/2)) && palindrome(s.substr((s.size()+1)/2,(s.size()-1)/2)))
    cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

nn = 200200
mod = 10**9+7

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % mod

inv = lambda i: fainv[i] * fa[i-1] % mod

N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

##### Settings
unit = 1
merge = lambda a, b: a * b % mod
adj_bu = lambda a, i=-1: a * fainv[SI[i]] % mod * fa[SI[i]-1] % mod
adj_td = lambda a, i=-1: a * fainv[N - SI[i]] % mod * fa[N - SI[i] - 1] % mod
calc = lambda i: merge(BU[i], TD[i]) * SI[i] % mod * fa[N - 1] % mod
#####

SI = [1] * N
for i in R[1:][::-1]:
    SI[P[i]] += SI[i]

BU = [unit] * N
TD = [unit] * N
for i in R[1:][::-1]:
    BU[i] = adj_bu(BU[i], i)
    p = P[i]
    BU[p] = merge(BU[p], BU[i])
BU[R[0]] = adj_bu(BU[R[0]], R[0])

AX = [0] * N
for i in R:
    ac = unit
    for j in X[i]:
        AX[j] = ac
        ac = merge(ac, BU[j])
    ac = unit
    for j in X[i][::-1]:
        AX[j] = merge(AX[j], ac)
        TD[j] = adj_td(merge(TD[i], AX[j]), j)
        ac = merge(ac, BU[j])

ANS = [calc(i) for i in range(N)]
print(*ANS, sep = "\n")

Measured memory_bytes: 125872
#include<iostream>

int dp[10001];

int main()
{
	dp[0] = 1;
	for( int i = 1; i <= 10000; i++ ){
		dp[i] = dp[i-1] + i;
	}
	
	int a;
	while( std::cin >> a ){
		std::cout << dp[a] << std::endl;
	}

 	return 0;
}

Measured memory_bytes: 1200
#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;

#define pow2(x) ((x)*(x))
ll calc(vector<int> &x,ll p) {
  ll ret = 0;
  rep(i,(int)x.size()) {
    ret += (ll)( pow2(x[i]-p) );
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  sort(ALL(x));
  vector<int> arr = x;
  arr.erase(unique(ALL(arr)),arr.end());
  ll mini = calc(x,x[0]);
  rep(i,(int)arr.size()) {
    mini = min(mini,calc(x,arr[i]));
    REP(j,i+1,(int)arr.size()) {
      ll m = (arr[i]+arr[j]) / 2;
      REP(d,-5,6) {
	mini = min(mini,calc(x,m+d));
      }
    }
  }
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	double cnt=n/2+n%2;
	double ans=cnt/n;
	
	printf("%.10f\n",ans);
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp::Ordering;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(Eq)]
struct Shop{
    index: usize,
    name: String,
    score: u64,
}

impl PartialEq for Shop {
    fn eq(&self, other: &Shop) -> bool {
        self.name == other.name && self.score == other.score
    }
}
 
impl PartialOrd for Shop {
    fn partial_cmp(&self, other: &Shop) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for Shop {
    fn cmp(&self, other: &Shop) -> Ordering{
        if self.name == other.name {
            other.score.cmp(&self.score)
        } else {
            self.name.cmp(&other.name)
        }
    }
}

fn main(){
    let n: usize = read();
    let mut s:Vec<Shop> = Vec::with_capacity(n);

    for i in 0..n {
        let e = Shop {
            index: i+1,
            name: read(),
            score: read(),
        };
        s.push(e);
    }
    s.sort();
    for e in &s{
        println!{"{}", e.index};
    }
}

Measured memory_bytes: 4352
def zeros(h,*w): return [[0] * w[0]  for _ in range(h)] if w else [[0] * h  for _ in range(h)]

n = int(input())
h = [ list(map(int, input().split())) for _ in range(n) ]

dp = zeros(n+1,3)

for i in range(n):
  dp[i+1][0] = max(dp[i][1], dp[i][2]) + h[i][0]
  dp[i+1][1] = max(dp[i][0], dp[i][2]) + h[i][1]
  dp[i+1][2] = max(dp[i][0], dp[i][1]) + h[i][2]

ans = max( dp[n] )

print(ans)

Measured memory_bytes: 47364
arr = [0]*100
while True:
    try:
        x,y,s = map(int, input().split(","))
        if s==3:
            if x <= 7:
                arr[10*y+x+2] += 1
            if x >= 2:
                arr[10*y+x-2] += 1
            if y <= 7:
                arr[10*y+x+20] += 1
            if y >= 2:
                arr[10*y+x-20] += 1
        if s>=2:
            if x != 9 and y != 9:
                arr[10*y+x+11] += 1
            if x != 9 and y != 0:
                arr[10*y+x-9] += 1
            if x != 0 and y != 0:
                arr[10*y+x-11] += 1
            if x != 0 and y != 9:
                arr[10*y+x+9] += 1
        if True:
            if x != 9:
                arr[10*y+x+1] += 1
            if x != 0:
                arr[10*y+x-1] += 1
            if y != 9:
                arr[10*y+x+10] += 1
            if y != 0:
                arr[10*y+x-10] += 1
        if True:
            if True:
                arr[10*y+x] += 1

    except EOFError:
        break

print(arr.count(0))
print(max(arr))

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

int main()
{
    vector<vector<int>> a(3,vector<int>(3));
    rep(i,3) rep(j,3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(i,n) {
        int b;
        cin >> b;
        rep(j,3) rep(k,3) if(a[j][k] == b) a[j][k] = -1;
    }
    
    rep(i,3) {
        bool bingo = true;
        rep(j,3) if(a[i][j] >= 0) bingo = false;
        if(bingo) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i,3) {
        bool bingo = true;
        rep(j,3) if(a[j][i] >= 0) bingo = false;
        if(bingo) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(a[0][0] < 0 && a[1][1] < 0 && a[2][2] < 0) {
        cout << "Yes" << endl;
        return 0;
    }
    if(a[0][2] < 0 && a[1][1] < 0 && a[2][0] < 0) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
S = [0]
H = [0]
C = [0]
D = [0]

for i in range(1, 14):
    S.append(i)
    H.append(i)
    C.append(i)
    D.append(i)

n = int(input())
for i in range(n):
    dataset = input().split(" ")
    card_type = dataset[0]
    card_number = int(dataset[1])

    if card_type == "S":
        S[card_number] = 0
    elif card_type == "H":
        H[card_number] = 0
    elif card_type == "C":
        C[card_number] = 0
    elif card_type == "D":
        D[card_number] = 0


for i in range(1, 14):
    if S[i] != 0:
        print("S %d" % S[i])

for i in range(1, 14):
    if H[i] != 0:
        print("H %d" % H[i])

for i in range(1, 14):
    if C[i] != 0:
        print("C %d" % C[i])

for i in range(1, 14):
    if D[i] != 0:
        print("D %d" % D[i])



Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX/2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }




void update(vector<int> & Segtree, int k, int a,int N)
{
  k += N -1;
  Segtree[k] = a;
  while(k > 0)
  {
    k = (k-1)/2;
    Segtree[k] = min(Segtree[2*k+1],Segtree[2*k + 2]);
  }
}

int query(vector<int> & Segtree,int a, int b, int k, int l,int r)
{
  // DEBUG(k);
  if(r <= a || b <= l) return 2147483647;
  if(a <= l && r <= b) return Segtree[k];
  else
  {
    int vl = query(Segtree,a,b,k*2+1,l,(r+l)/2);
    int vr = query(Segtree,a,b,k*2+2,(l+r)/2,r);
    return min (vr,vl);
  }

  

}

void solve(void)
{
  int X;
  cin>>X;
  if( X - 1 == 0)
  {
    cout<<1<<endl;
    return;
  }
  X--;
  int Y = X/11;
  X = X%11;

  if(X < 6)
  {
    cout<<2*Y  + 1 <<endl;
  }
  else
  {
    cout<<2*Y + 2 <<endl;
  }
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <fstream>
using namespace std;
#define ll long long int


int main( ) {
  int n,k;
  string s;
  cin >> n >> k >> s;
  
  vector <int> compressed_s;
  int now = 1;
  int cnt = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( s[i] == (char)(now + '0') ) cnt++;
    else {
      compressed_s.push_back(cnt);
      now = 1 - now;
      cnt = 1;  
    }
  }
  if(cnt != 0)compressed_s.push_back(cnt);
  int comp_size = compressed_s.size();

  if (comp_size % 2 == 0 ) compressed_s.push_back(0);
  int add = 2 * k + 1;

  vector<int> comulative_compressed_s(comp_size + 1);
  for ( int i = 0; i < comp_size; i++ ) {
    comulative_compressed_s[i + 1] = comulative_compressed_s[i] + compressed_s[i];  
  }
  
  int ans = 0;
  for ( int i = 0; i < comp_size; i += 2 ) {
    int left  = i;
    int right = min(i + add, comp_size);
    int tmp   = comulative_compressed_s[right] - comulative_compressed_s[left];
    
    ans = max(tmp,ans); 
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1336
#include<cstdio>
const int N=1000020;
char s[N],t[N];
int n,m,p,kmp[N],i,k;
int main(){
	scanf("%d%s%s",&p,s,t);
	while(s[n])n++;
	while(t[m])m++;
	for(i=1;i<m;i++){
		while(k&&t[i]!=t[k])
			k=kmp[k];
		if(t[i]==t[k])
			kmp[i+1]=++k;
	}
	for(i=k=0;i<n;i++){
		while(k&&s[i]!=t[k])
			k=kmp[k];
		if(s[i]==t[k])
			k++;
	}
	while(1){
		if(n+m-k>=p){
			printf("%d",n+m-k);
			//while(1);
			return 0;
		}
		if(k==0){
			printf("%d",p);
			//while(1);
			return 0;
		}
		k=kmp[k];
		
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int inf = 0x3f3f3f3f;
const int MOD = 998244353;
const ll INF = 1000000000000000010LL;


int n;
int a[maxN],b[maxN];
double get(int x,int y)
{
	ll tmp = (a[x]-a[y])*(a[x]-a[y]) + (b[x]-b[y])*(b[x]-b[y]);
	return sqrt(tmp);
}
int c[maxN];
int vis[maxN];
double ans;
void dfs(int tot)
{
	if(tot > n)
	{
		for(int i=1;i<n;i++)
		{
			ans += get(c[i],c[i+1]);
		}
		return;
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i] == 0)
		{
			c[tot] = i;
			vis[i] = 1;
			dfs(tot+1);
			vis[i] = 0;
		}
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
	}
	ans = 0;
	dfs(1);
	int len = 1;
	for(int i=1;i<=n;i++)
	{
		len *= i;
	}
	ans /= len;
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 256