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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> arr(H, vector<char>(W));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> arr.at(i).at(j);
    }
  }
  
  for (int i = 0; i < H; ++i) {
    
    bool isEmpty = true;
    for (int j = 0; j < W; ++j) {
      if (arr.at(i).at(j) == '#') isEmpty = false;
    }
    if (isEmpty) {
      for (int j = 0; j < W; ++j) {
        arr.at(i).at(j) = ' ';
      }
    }
  }
  for (int j = 0; j < W; ++j) {
    
    bool isEmpty = true;
    for (int i = 0; i < H; ++i) {
      if (arr.at(i).at(j) == '#') isEmpty = false;
    }
    if (isEmpty) {
      for (int i = 0; i < H; ++i) {
        arr.at(i).at(j) = ' ';
      }
    }
  }
  
  for (int i = 0; i < H; ++i) {
    bool isEmptyColumn = true;
    for (int j = 0; j < W; ++j) {
      bool isEmpty = false;
      if (arr.at(i).at(j) == ' ') {
        isEmpty = true;
        isEmptyColumn = isEmptyColumn && true;
      } else {
        isEmptyColumn = isEmptyColumn && false;
      }
      if (!isEmpty) cout << arr.at(i).at(j);
    }
    if (!isEmptyColumn) cout << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b, c, d, ans;
  cin >> a >> b >> c >> d;
  ans = max(a * b, c * d);
  cout << ans << endl;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    lli a , b , c , d , R , E;
    cin >> a >> b >> c >> d ;
    R = a * b ;
    E = c * d ;

    if (R > E)
        cout << R ;
    else if (R < E)
        cout << E ;
    else
        cout << R ;

    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll h, w;
    cin >> h >> w;

    if(h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }

    if(w % 2 == 0){
        cout << w / 2 * h << endl;
    }else{
        if(h % 2 == 0){
            cout << h / 2 * w << endl; 
        }else{
            cout << ((h / 2) * w ) + (w/2)+1 << endl;
        }
    }

    /*
    if(h == w){
        cout << h << endl;
    }else if(h % 2 != 0 && ){
        cout << (h*w / 2) << endl;
    }else{
        cout << ((h / 2) * (w / 2)) + 1 << endl;
    }
    ll a = 1000000000 * 1000000000;
    cout << a << endl;
    */
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

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

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

int main(){
	
	string T, P;
	cin >> T >> P;
	
	if(T.size() < P.size()){
		return 0;
	}
	
	unsigned long long int P_val = 0, T_val = 0, MOD_P = 1;
	
	for(int i = 0; i < P.size(); i++){
		P_val *= MOD;
		P_val += P[i];
		MOD_P *= MOD;
	}
	
	for(int i = 0; i < P.size(); i++){
		T_val *= MOD;
		T_val += T[i];
	}
	
	if(T_val == P_val){
		cout << 0 << endl;
	}
	
	for(int i = P.size(); i < T.size(); i++){
		T_val *= MOD;
		T_val += T[i];
		T_val -= MOD_P * T[i - P.size()];
		if(T_val == P_val){
			cout << i - P.size() + 1 << endl;
		}
	}
	
	return 0;
}



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

int main()
{
    int n;
    int k[10005];
    int f = 0;
    int ans = 0;

    while (cin >> n, n != 0) {
        f = 0;
        ans = 0;
        
        for (int i = 0; i < n; i++) {
            cin >> k[i];

            if (k[i] >= 2) f = 1;
            if (k[i] > 0) ans++;
        }

        if (f) {
            cout << ans + 1 << endl;
        }
        else {
            cout << "NA" << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
using namespace std;

int main(){
  int a,b,c,count=0;
  cin >> a >> b >> c;
  if (a!=b){
    for (int i=a;i<b+1;i++){
      if(c%i==0)count++;
    }
  }
  else{
    if(c%a==0)count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 3096
n, m = map(int, input().split())
L = ["WA" for i in range(n + 1)]
wa = [0 for i in range(n + 1)]

ac = 0
penalty = 0
for i in range(m):
    s, p = map(str, input().split())
    s = int(s)
    if L[s] == "AC":
        continue

    if L[s] == "WA" and p == "WA":
        wa[s] += 1
    elif L[s] == "WA" and p == "AC":
        L[s] = "AC"
        ac += 1
        penalty += wa[s]


print(ac, penalty)

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

using namespace std;

int powMod(int x, int y, int z) {
  long long ret = 1;
  for (; y; y >>= 1, x = (long long)x * x % z) {
    if (y & 1)
      ret = ret * x % z;
  }
  return ret;
}

const int mod = 998244353;

long long C[2222][2222];
long long f[2222][2222];

int main(int argc, char *argv[]) {
  int K, n;
  cin >> K >> n;
  for (int i = 0; i <= 2000; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) {
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
    }
  }
  f[0][0] = 1;
  for (int i = 1; i <= 2000; i++) {
    f[i][0] = f[i - 1][0];
    for (int j = 1; j <= 2000; j++) {
      f[i][j] = (f[i - 1][j] + f[i][j - 1]) % mod;
    }
  }
  for (int i = 2; i <= 2 * K; i++) {
    int extra = 0, s1 = 0, s2 = 0;
    for (int j = 1; j <= K; j++) {
      if (j * 2 == i) {
        extra++;
      } else if (i - j <= K && i - j > 0) {
        s1 += (i - j < j);
      } else {
        s2++;
      }
    }
    auto solve = [&](int n, int s1, int s2) {
      long long ans = 0;
      for (int i = 0; i <= s1 && i <= n; i++) {
        ans = (ans + C[s1][i] * f[s2 + i][n - i] % mod * powMod(2, i, mod)) % mod;
      }
      return ans;
    };
    cout << (solve(n, s1, s2) + (extra ? solve(n - 1, s1, s2) : 0 )) % mod << endl;
  }
  return 0;
}


Measured memory_bytes: 71936
import java.util.Scanner

import scala.annotation.tailrec
import scala.io.StdIn._

object Main extends App {

  val Array(a,b,c,d) = readLine().split(" ").map(_.toInt)

  def solve() = {
    val aAtkCount = ceil(a,d)
    val tAtkCount = ceil(c,b)
    if(tAtkCount <= aAtkCount) "Yes" else "No"
  }

  def ceil(a: Int, b: Int): Int = (a+b-1)/b

  println(solve())

}



Measured memory_bytes: 54772
import java.util.Scanner;

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

		int N = scan.nextInt();
		int Y = scan.nextInt();

		int output1000 = 0;
		int output5000 = 0;
		int output10000 = 0;

		findRoop: for (int sen = 0; sen <= N; sen++) {
			for (int gosen = 0; gosen <= N - sen; gosen++) {
				if (1000*sen + 5000*gosen + 10000*(N-sen-gosen) == Y) {
					output1000 = sen;
					output5000 = gosen;
					output10000 = N - sen - gosen;
					break findRoop;
				}
			}
		}

		if (output1000 == 0 && output5000 == 0 && output10000 == 0) {
			System.out.print(-1 + " " + -1 + " " + -1);
		} else {
			System.out.print(output10000 + " " + output5000 + " " + output1000);
		}
	}

}

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

const int maxn = 1e5 + 5;
int c0[maxn], c1[maxn];

int main()
{
	memset(c0, 0, sizeof(c0));
	memset(c1, 0, sizeof(c1));
	int n;	cin >> n;
	int m0 = 0, m1 = 0;	// cnt
	int n0 = 0, n1 = 0;
	int mm0 = 0, mm1 = 0;	// cnt
	int nn0 = 0, nn1 = 0;
	for(int i = 0; i < n; i ++)
	{
		int x;	cin >> x;
		if(i % 2 == 0)
		{
			c0[x] ++;
			if(c0[x] > m0)	{ m0 = c0[x];	n0 = x; }
			else if(c0[x] > mm0)	{ mm0 = c0[x];	nn0 = x; }
		}
		else
		{
			c1[x] ++;
			if(c1[x] > m1)	{ m1 = c1[x];	n1 = x; }
			else if(c1[x] > mm1)	{ mm1 = c1[x];	nn1 = x; }
		}
	}
	
	if(n0 != n1)	cout << n - m0 - m1 << endl;
	else	cout << n - m0 - max(mm0, mm1) << endl;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc= new Scanner(System.in);
       final int a=sc.nextInt();
       final int b=sc.nextInt();
  if(a<b){
System.out.println("a < b");
  }else if(a>b){
    System.out.println("a > b");
  }else{
    System.out.println("a == b");
  }
  sc.close();
}


    }




Measured memory_bytes: 26212
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=310,mod=998244353;
int n,ans,sm,a[N],f[N*N],g[N*N];

int ksm(int a,int b){
	int res=1;
	for (; b; a=1ll*a*a%mod,b>>=1)
		if (b & 1) res=1ll*res*a%mod;
	return res;
}

int main(){
	scanf("%d",&n); ans=(ksm(3,n)-3ll*ksm(2,n)+3+3ll*mod)%mod;
	rep(i,1,n) scanf("%d",&a[i]),sm+=a[i];
	f[0]=g[0]=1;
	rep(i,1,n) for (int j=sm; ~j; j--){
		f[j]=(f[j]*2ll+(j>=a[i]?f[j-a[i]]:0))%mod;
		g[j]=(g[j]+(j>=a[i]?g[j-a[i]]:0))%mod;
	}
	rep(i,(sm+1)/2,sm-1) ans=(ans-3ll*(f[i]-2ll*g[i])+3ll*mod)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int n;
    cin>>n;
    if(n==1){
        printf("Yes\n2\n");
        printf("1 1\n");
        printf("1 1\n");
        return 0;
    }
    int k = -1;
    rep1(i,n){
        if(i*(i-1)/2 == n) {
            k = i;
        }
    }
    if(k == -1){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl<<k<<endl;
    int g[1000][1000] = {};
    int cnt = 1;
    rep1(i,k)rep1(j,k)if(i!=j && g[i][j]==0){
        g[i][j] = g[j][i] = cnt;
        cnt++;
    }
    assert(cnt == n+1);
    rep1(i,k){
        cout<<k-1;
        rep1(j,k)if(i!=j){
            cout<<" "<<g[i][j];
        }
        cout<<endl;
    }

    return 0;
}


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

int main(){
    int l; cin >> l;;
    int k = 0; while((1<<k) <= l) k++;
    int bit = __builtin_popcount(l) - 1;
    cout << k << " " << 2*(k-1)+bit << endl;
    int count = 1<<(k-1);
    rrep(i,k-1){
        cout << i+1 << " " << i+2 << " " << (1<<i) << endl;
        cout << i+1 << " " << i+2 << " " << 0 << endl;
        if((1<<i)&l){
            cout << i+1 << " " << k << " " << count << endl;
            count += 1<<i;
        }
    }
}

Measured memory_bytes: 3600
n = int(input())
alst = list(map(int, input().split()))
blst = list(map(int, input().split()))
ans = 0
car = 0
for i in range(n):
  plus = min(blst[i] + car, alst[i])
  ans += plus
  if plus == alst[i]:
    car = blst[i] + car - alst[i]
    car = min(car, blst[i])
  else:
    car = 0
ans += min(car, alst[-1])
print(ans)

Measured memory_bytes: 97256
string_len, question_num = STDIN.gets.split.map(&:to_i)
question_str = STDIN.gets.chomp

index = [0] * (string_len + 1)

(question_str.size - 1).times do |i|
  if question_str.slice(i, 2) == 'AC'
    index[i + 1] = index[i] + 1
  else
    index[i + 1] = index[i]
  end
end

question_num.times do |_|
  l, r = STDIN.gets.split.map(&:to_i)
  STDOUT.puts index[r-1] - index[l-1]
end

Measured memory_bytes: 3324
#include<stdio.h>
#include<string.h>
#define N 100001
int main(){
  int n,q,i,j,Time[N],end=0,head=0,tail=0,k=0,sumtime=0;
  char name[N][11];
  scanf("%d%d",&n,&q);
  tail=n;
  
  for(i=0;i<n;i++){
    scanf("%s%d",name[i],&Time[i]);
  }
  while(1){
    if(n==end)
      break;
    if(Time[head]<=q&&Time[head]!=0){
      printf("%s %d\n",name[head],sumtime+Time[head]);
      sumtime+=Time[head];
      Time[head]=0;
      head++;
      if(head==N)
	head=0;
      end++;
    }
    else{
      Time[head]-=q;
      sumtime+=q;
      strcpy(name[tail],name[head]);
      Time[tail++]=Time[head];
      if(tail==N)
	tail=0;
      head++;
      if(head==N)
	head=0;
    }

  }

  return 0;
}



Measured memory_bytes: 3160
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;
//---------------------------------------------------------------
using Point = complex<double>;
using Polygon = vector<Point>;
double dot(const Point& a, const Point& b) { return real(conj(a) * b); }
double cross(const Point& a, const Point& b) { return imag(conj(a) * b); }

double area(Polygon ps) {
    double sum = 0;
    for (int i = 0; i < ps.size(); i++) {
        sum += cross(ps[i], ps[(i + 1) % ps.size()]);
    }
    return abs(sum) / 2;
}
//---------------------------------------------------------------

#include <iomanip>      // cout << fixed << setprecision(1)
#include <iostream>
int main() {
    int n, cnt = 0;
    while (cin >> n, n) {
        cnt++;
        vector<Point> ps(n);
        int x, y;
        for (int i = 0; i < n; i++) {
            cin >> x >> y;
            ps[i] = Point(x, y);
        }
        double ans = area(ps);
        cout << fixed << setprecision(1);
        cout << cnt << " " << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3220
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var ringyou = new long[N + 1, N + 1];
            for(var i=1;i<=N;++i)
            {
                var ukv = Sarray();
                for(var j=2;j<ukv.Length;++j)
                {
                    ringyou[i, ukv[j]] = 1;
                }
            }
            StringBuilder ans = new StringBuilder();
            for(var i=1;i<=N;++i)
            {
                for(var j=1;j<=N;++j)
                {
                    ans.Append($"{ringyou[i, j]} ");
                }
                WriteLine(ans.ToString().Trim());
                ans = new StringBuilder();
            }
        }
    }
}


Measured memory_bytes: 18456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

const long long INF = 1LL<<40;

int main(void){
    ll n, k;
    cin >> n >> k;

    vector<vector<ll>> s(n);
    rep(i, 0, n){
        ll t, d;
        cin >> t >> d;
        --t;
        s[t].push_back(d);
    }

    for(auto &v: s){
        sort(v.begin(), v.end(), greater<ll>());
        if(v.empty()) v.push_back(-INF);
    }

    sort(s.begin(), s.end(), [&](vector<ll> a, vector<ll> b){return a[0] > b[0];});

    ll cur = 0;
    priority_queue<ll> que;
    rep(i, 0, k){
        cur += s[i][0];
        rep(j, 1, s[i].size())
            que.push(s[i][j]);
    }

    rep(i, k, n){
        rep(j, 0, s[i].size()) que.push(s[i][j]);
    }

    ll res =  cur + k * k;
    rrep(x, k-1, 1){
        ll v = s[x][0];
        ll w = que.top();
            que.pop();
            cur += w;
            que.push(v);
            cur -= v;
        res = max(res, cur + x*x);
    }
    cout << res << endl;
}


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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  
  for (int x = 0; x <= K; x++){
    for (int y = 0; y <= K; y++){
        int z = S - x - y;
        if (x + y + z == S && z >= 0 && z <= K){
          count++;}
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	m := []string{}
	for i := 0; i <= len(s)-len(t); i++ {
		ss := s[0:i] + t + s[i+len(t):]
		ok := true
		for j := 0; j < len(s); j++ {
			if s[j] == '?' || s[j] == ss[j] {
				continue
			}
			ok = false
		}
		if ok {
			m = append(m, ss)
		}
	}

	if len(m) == 0 {
		fmt.Println("UNRESTORABLE")
	} else {
		sort.Strings(m)
		ans := strings.Replace(m[0], "?", "a", -1)
		fmt.Println(ans)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 111;

int n, a[N];
int dp[N][5][5][5];

int mapping(char c){
   if(c == 'A')return 0;
   if(c == 'G')return 1;
   if(c == 'C')return 2;
   return 3;
}

vector<char> v;
int solve(int idx, int P3, int P2, int P1){
   if(idx >= n){
      return 1;
   }

   int &ans = dp[idx][P3+1][P2+1][P1+1];
   if(ans != -1)
      return ans;

   ans = 0;
   for(auto it: v){
      if(it == 'G' and P2 == 0 and P1 == 2){
         continue;
      }
      if(it == 'C' and P2 == 0 and P1 == 1){
         continue;
      }
      if(it == 'C' and P2 == 1 and P1 == 0){
         continue;
      }
      if(it == 'C' and P3 == 0 and P1 == 1 and (P2 >= 1)){
         continue;
      }
      if(it == 'C' and P3 == 0 and P2 == 1 and (P1 != 2)){
         continue;
      }
      ans += solve(idx+1, P2, P1, mapping(it));
      if(ans >= mod)ans -= mod;
   }

   return ans;
}

int32_t main(){_

   cin>>n;
   v = {'A', 'G', 'C', 'T'};
   
   int ans = 0;
   memset(dp, -1, sizeof dp);
   // for (int i = 0; i < sz(v); ++i)
   // {
   //    for (int j = 0; j < sz(v); ++j)
   //    {
   //       for (int k = 0; k < sz(v); ++k)
   //       {
   //          string str(1, v[i]);
   //          str += v[j];
   //          str += v[k];
   //          if(str == "ACG" or str == "GAC" or str == "AGC")continue;
   //          ans += solve(3, mapping(str[0]), mapping(str[1]), mapping(str[2]));
   //          ans %= mod;
   //       }
   //    }
   // }
   cout<<solve(0, -1, -1, -1);
   // cout<<ans;
   #warning make sure N size is correct!
   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int x[10], y[10];

double dist(int i, int j){
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx*dx + dy*dy, 0.5);
}

int main(){
  int N, fact = 1; cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
    v[i] = i;
  }
  for(int i = 1; i <= N; i++){
    fact *= i;
  }
  double sum = 0;
  do{
    for(int i = 0; i < N - 1; i++){
      sum += dist(v[i], v[i + 1])/fact;
    }
  }while(next_permutation(v.begin(), v.end()));
  cout << fixed << setprecision(10) << sum << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

ll powMod(ll x, ll n) {
  if (n == 0) return 1;
  ll r = powMod(x, n / 2);
  if (n % 2 == 0) return (r * r) % MOD;
  return (r * r % MOD) * x % MOD;
}


int main(void) {

  char s[30][30];
  int h, w;
  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> s[i][j];

  int z = 0;
  int num[30][30];
  rep(i, h) rep(j, w) {
    if (s[i][j] == '.') num[i][j] = z++;
    else num[i][j] = -1;
  }
  /*rep(i, h) {
    rep(j, w) {
      cout << num[i][j] << " ";
    }
    cout << endl;
  }*/

  int g[500][500] = {};
  rep(i, z) rep(j, z) g[i][j] = 100000000;
  rep(i, z) g[i][i] = 0;
  
  rep(i, h) rep(j, w) {
    for (int k = -1; k <= 1; k ++) {
      for (int l = -1; l <= 1; l ++) {
	if (0 <= i+k && i+k <= h-1 && 0 <= j+l && j+l <= w-1) {
	  if (s[i][j] == '#' || s[i+k][j+l] == '#') continue;
	  if (k*l != 0) continue;
	  //cout << num[i][j] << " " << num[i+k][j+l] << endl;
	  g[num[i][j]][num[i+k][j+l]] = 1;
	  g[num[i+k][j+l]][num[i][j]] = 1;
	}
      }
    }
  }
  //cout << "g[0][3] = " << g[0][3] << endl;

  rep(k, z) rep(i, z) rep(j, z) {
    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  }

  int ans = 0;

  rep(i, z) rep(j, z) ans = max(ans, g[i][j]);
  cout << ans << endl;

}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main(void){
	int i,j,s1,s2;
	string SS,S1,S2;
	cin >> SS;
	S1 = "0";
	S2 = "0";
	s1 = 0;
	s2= 0;
	for(i=0;i<4&&s1<=2&&s2<=2;i++){
		if(S1=="0"){
			S1=SS.substr(0,1);
			s1 = 1;
			continue;
		}
		if(S1==SS.substr(i,1)){
			s1 += 1;
			continue;
		}else{
			if(S2=="0"){
				S2=SS.substr(i,1);
				s2=1;
				continue;
			}
			if(S2==SS.substr(i,1)){
				s2+=1;
				continue;
			}else{
				cout << "No";
				return 0;
			}
		}
	}
	if(s1!=2){
		cout<<"No";
	}else{
		cout << "Yes";
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
String = str(input())
Mid = len(String) // 2 
StrFormer = String[0:Mid]
StrFormer_inv = StrFormer[::-1]
StrLater = String[:Mid:-1]
StrLater_inv = StrLater[::-1]
if StrFormer == StrFormer_inv and StrLater == StrLater_inv:
    if StrFormer == StrLater:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;

int main(){
   int r,d,x;   cin >> r >> d >> x;

   for(int i=1;i<=10;i++){
       x = r*x-d;
       cout << x << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from itertools import islice
import operator

N, K = map(int, input().split())
sushi = [tuple([i] + [int(x) for x in input().split()]) for i in range(N)]
sushi.sort(key=operator.itemgetter(2), reverse=True)

from collections import OrderedDict, deque, Counter
left = OrderedDict((x[0], x) for x in sushi)

base = 0
choosen = [None] * N
choosen_kind = set()
ci = 0
for x in sushi:
    i, t, _ = x
    if t not in choosen_kind:
        choosen[ci] = x
        ci += 1
        choosen_kind.add(t)
        del left[i]

choosen = choosen[:min(ci, K)]
base = sum(d for _,_,d in choosen)
kinds = len(choosen)

cands = islice(left.values(), K)
fixed = islice(cands, K - len(choosen))
base += sum(d for _,_,d in fixed)

score = base + kinds**2

for cand in cands:
    if cand[2] <= choosen[-1][2]:
        break

    base_n = base
    base_n -= choosen[-1][2]
    base_n += cand[2]
    kinds_n = kinds - 1
    
    score_n = base_n + kinds_n**2
    if score_n > score:
        choosen.pop()
        base, kinds, score = base_n, kinds_n, score_n
    else:
        break

print(score)

Measured memory_bytes: 51960
k=int(input())
if k%7==0:
    k//=7
res=1
if k%2==0 or k%5==0:
    print(-1)
else:
    k*=9
    for i in range(k):
        res*=10
        if res%k==1:
            print(i+1)
            break
        else:
            res%=k


Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
// const ll MOD = 1e9+7;
const ll MOD = 998244353;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
    vector<P> s;
    rep(i,k) {
        int l, r;
        cin >> l >> r;
        s.push_back(make_pair(l,r));
    }
    vector<ll> dp(2*n);
    dp[n] = 1;
    ll cum = 0;
    rep(i,n-1) {
        for (P p: s) {
            cum += dp[i+n+1-p.first];
            cum -= dp[i+n+1-p.second-1];
            cum += 2 * MOD;
            cum %= MOD;
        }
        dp[i+n+1] = cum;
    }
    cout << dp[2*n-1] << endl;
	return 0;
}


Measured memory_bytes: 6364
let read () = Scanf.scanf "%d " (fun i -> i)

let () =
  let n = read () in
  let a = Array.init n (fun _ -> read ()) in
  Array.fast_sort (fun x y -> y - x) a;
  let rec doit i pre =
    if i = n then 0
    else if a.(i-1) = a.(i) then begin
      if pre <> (-1) then pre * a.(i)
      else doit (i + 2) a.(i)
    end else doit (i + 1) pre in
  doit 1 (-1) |> Printf.printf "%d\n"

Measured memory_bytes: 5504
#include <iostream>

using namespace std;

int nanzyo(long long a){

  int i = 0;

  while((a/=10)!=0) i++;

  return i;
}

int main(void){

  int N;
  long long A[100000];
  long long x = 1;

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(A[i] == 0){
      cout << 0 << endl;
      break;
    }
    if(nanzyo(A[i])+nanzyo(x)<18 || A[i]*x==1000000000000000000){
      x*=A[i];
    } else if(i==N-1){
      cout << -1 << endl;
      break;
    }
    if(i==N-1 && x<=1000000000000000000) cout << x << endl;
    else if(i==N-1)cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(x,a)for(auto &x: a)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll>pii;
typedef vector<ll>vi;
typedef map<ll,ll>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}

int main()
{
	//fopen();
	int n;
	cin>>n;
	vector<int>a[200001];
	rep(i,n)
	{
		int p;cin>>p;
		a[p].pb(i);
	}
	rep(i,200001){
		sort(a[i].begin(),a[i].end());
	}
	//sort(a.begin(),a.end());
	if(a[1].size()==0)
	{
		cout<<-1;
		exit(0);
	}
	int s=1,p=a[1][0];

	//rep(i,n){cout<<a[i].F;}
	repA(2,i,n+1)
	{
		if(a[i].size()==0)
			{break;}
		int k=p;
		rep(j,a[i].size())
		{
			if(a[i][j]>p)
				{p=a[i][j];s+=1;break;}
		}
		if(k==p)
			{break;}
	}
	cout<<n-s;
	//cout<<m<<" "<<e;
	
	
}
	


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, k, r, s, p;
string t;
char choice[3] = {'r', 's', 'p'};
map<char, int> m;
map<char, char> beats;
vector<string> vs;

int max_k_stride(string s){
    int s_size = s.size();
    int ret = 0;
    char prev;
    for(int i=0; i<3; i++){
        prev = s[0];
        int tmp = 0;
        if(beats[s[0]] == choice[i]) tmp += m[s[0]];
        for(int j=1; j<s_size; j++){
            if(prev != s[j]){
                tmp += m[s[j]];
                prev = s[j];
            }else{
                prev = 'a';
            }
        }
        ret = max(ret, tmp);
    }
    return ret;
}

signed main(void){
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;

    m.insert(P('r', p));
    m.insert(P('s', r));
    m.insert(P('p', s));

    beats.insert(P('r', 'p'));
    beats.insert(P('s', 'r'));
    beats.insert(P('p', 's'));

    vs.resize(k);
    for(int i=0; i<n; i++){
        vs[i%k] += t[i];
    }

    int ret = 0;
    for(string str: vs){
        ret += max_k_stride(str);
    }
    cout << ret << endl;
}

Measured memory_bytes: 5120
using System;

namespace ITP1_6_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            bool[] s = new bool[14];
            bool[] h = new bool[14];
            bool[] c = new bool[14];
            bool[] d = new bool[14];
            while (n-- != 0)
            {
                string[] strs = Console.ReadLine().Split(' ');
                char kind = char.Parse(strs[0]);
                int num = int.Parse(strs[1]);
                switch (kind)
                {
                    case 'S':s[num] = true; break;
                    case 'H':h[num] = true; break;
                    case 'C':c[num] = true; break;
                    case 'D':d[num] = true; break;
                    default: break;
                }
            }

            for (int i = 1; i < 14; i++) if (!s[i]) Console.WriteLine("S " + i);
            for (int i = 1; i < 14; i++) if (!h[i]) Console.WriteLine("H " + i);
            for (int i = 1; i < 14; i++) if (!c[i]) Console.WriteLine("C " + i);
            for (int i = 1; i < 14; i++) if (!d[i]) Console.WriteLine("D " + i);
        }
    }
}

Measured memory_bytes: 9048
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

bool ok(string s, int k)
{
    int convert = 0;
    int n = s.size();
    rep (i, n - k)
    {
        if ((s[i] == '1' && convert == 0) || (s[i] == '0' && convert == 1))
        {
            convert ^= 1;
        }
    }
    bool ret = true;
    for (int i = n - k; i < k; ++i)
    {
        if (s[n - k] != s[i]) ret = false;
    }
    return ret;
}

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

    string s;
    cin >> s;
    int n = s.size();

    int l, r;
    l = CEIL(n, 2);
    r = n + 1;
    while (l + 1 < r)
    {
        int m = (l + r) / 2;
        if (ok(s, m))
        {
            l = m;
        }
        else
        {
            r = m;
        }
    }

    cout << l << "\n";
    return 0;
}



Measured memory_bytes: 512
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

#if 0
const int limit = 100010;
int r[limit];
int t[limit], x[limit], y[limit];
map<int, int> m;

bool travel(int t, int max_n, int cur_x, int cur_y)
{
	if (t > max_n)
	{
		return true;
	}

	int x_[4] = {1, -1, 0, 0};
	int y_[4] = {0, 0, 1, -1};

	bool ret = false;

	rep(i, 4)
	{
		int new_x = cur_x + x_[i];
		int new_y = cur_y + y_[i];
		//cout << t << "; " << m[t] << "; x=" << new_x << "; y=" << new_y << endl;
		if (m[t] != 0)
		{
			if ((x[m[t]-1] == new_x) && (y[m[t]-1] == new_y))
			{
				return travel(t+1, max_n, new_x, new_y);
			}
		}
		else
		{
			ret |= travel(t+1, max_n, new_x, new_y);
		}
		
	}
	return ret;
}

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

	int n;
	
	cin >> n;

	//int t[n], x[n], y[n];

	//int r[n];
	//int x_[4] = {1, -1, 0, 0};
	//int y_[4] = {0, 0, 1, -1};

	rep(i, n)
	{
		cin >> t[i] >> x[i] >> y[i];
		m[t[i]] = i+1;
	}

	if (travel(1, t[n-1], 0, 0))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}
#endif

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

	int n;
	
	cin >> n;

	int t[n+1], x[n+1], y[n+1];

	//int r[n];
	//int x_[4] = {1, -1, 0, 0};
	//int y_[4] = {0, 0, 1, -1};
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;

	bool ret = true;
	rep(i, n)
	{
		cin >> t[i+1] >> x[i+1] >> y[i+1];
		if (ret)
		{
			int tt = t[i+1] - t[i];
			int dd = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
			if ((tt < dd) || ((tt % 2) != (dd % 2)))
			{
				ret = false;
			}
		}
		
	}

	if (ret)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	
	return 0;
}


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

using namespace std;

const int MOD = 1e9+7;

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

	int N, K;
	cin >> N >> K;

	vector<int> v(N);
	for(auto &i : v) cin >> i;

	vector<vector<int>> dp(N+1, vector<int>(K+1, 0)), sum(N+1, vector<int>(K+1, 0));
	dp[0][0] = 1;

	for(int i=1; i<=N; i++){
		sum[i-1][0] = dp[i-1][0];
		//precalc sum[i][j]
		for(int j=1; j<=K; j++)
			sum[i-1][j] = (sum[i-1][j-1] + dp[i-1][j]) % MOD;
		for(int j=0; j<=K; j++){
			dp[i][j] = sum[i-1][j];
			if(j - v[i-1] - 1 >= 0)
				dp[i][j] = (dp[i][j] - sum[i-1][j-v[i-1]-1] + MOD) % MOD;
		}
	}
/*
	for(auto i : dp){
		for(auto j : i)
			cout << j << " ";
		cout << "\n";
	}
*/
	cout << dp[N][K];
}



Measured memory_bytes: 79736
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] numa = new int[6];
		for(int i=0;i<6;i++){
			numa[i]=sc.nextInt();
		}
		Dice2 da = new Dice2(numa);
		int[] numb = new int[6];
		for(int i=0;i<6;i++){
			numb[i]=sc.nextInt();
		}
		Dice2 db = new Dice2(numb);
		if(check(da,db)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
	static boolean check(Dice2 d1,Dice2 d2){
		int up=0,fr=0;
		boolean yn=true;
		for(int i=0;i<6;i++){
			//System.out.println(d1.label[0]+"/"+d2.label[i]);
			if(d1.label[0]==d2.label[i]){
				up=i;
			}
		}
		for(int i=0;i<6;i++){
			//System.out.println(d1.label[1]+"/"+d2.label[i]);
			if(d1.label[1]==d2.label[i]){
				fr=i;
			}
		}
		//System.out.println("//"+up+fr);
		//System.out.println(rcheck(up, fr)+" "+d1.label[2]);
		if(d2.label[rcheck(up, fr)]!=d1.label[2]){
			yn=false;
		}
		return yn;
	}
	static int rcheck(int up,int fr){
		int a=0;
		if(up==0){
			if(fr==1){
				a=2;
			}else if(fr==2){
				a=4;
			}else if(fr==3){
				a=1;
			}else if(fr==4){
				a=3;
			}
		}else if(up==1){
			if(fr==0){
				a=3;
			}else if(fr==2){
				a=0;
			}else if(fr==3){
				a=5;
			}else if(fr==5){
				a=2;
			}
		}else if(up==2){
			if(fr==0){
				a=1;
			}else if(fr==1){
				a=5;
			}else if(fr==4){
				a=0;
			}else if(fr==5){
				a=4;
			}
		}else if(up==3){
			if(fr==0){
				a=4;
			}else if(fr==1){
				a=0;
			}else if(fr==4){
				a=5;
			}else if(fr==5){
				a=1;
			}
		}else if(up==4){
			if(fr==0){
				a=2;
			}else if(fr==2){
				a=5;
			}else if(fr==3){
				a=0;
			}else if(fr==5){
				a=3;
			}
		}else if(up==5){
			if(fr==1){
				a=3;
			}else if(fr==2){
				a=1;
			}else if(fr==3){
				a=4;
			}else if(fr==4){
				a=2;
			}
		}
		return a;
	}

}

class Dice2{
	int[] label=new int[6];
	Dice2(int[] a){
		for(int i=0;i<6;i++){
			label[i]=a[i];
		}
	}
}

Measured memory_bytes: 26372
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;
    if(k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
	int n,k;
	cin>>n>>k;
	int arr[n];
	for (int i = 0; i<n; i++){
		cin>>arr[i];
	}
	sort(arr, arr+n);
	int ans = 0;
	for (int i = 0; i<k; i++){
		ans+=arr[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
main(){
  int i,j,k,l,n,cnt=0;

  while(1){
    if(scanf("%d",&n) == EOF) break;
    cnt=0;
      for(i=0;i<=9;i++){
	for(j=0;j<=9;j++){
	  for(k=0;k<=9;k++){
	    for(l=0;l<=9;l++){
	      if(i+j+k+l==n) cnt++;
	    }
	  }
	}
      }
      printf("%d\n",cnt);
  }
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fr first
#define sc second
#define pb push_back
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
const int INF = 1e9+7;
const int MAXN = 1e5 + 200;
const  long double eps = 1e-16;
const long double pi = acos(-1.0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

long long h, n;
long long a[MAXN];
void solve(){
    cin >> h >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for (int i = n; i >= 1; i--){
        h -= a[i];
        if (h <= 0){
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}



int main() {
ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
cout.setf(ios::fixed), cout.precision(7);
 //freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
 int step;
 step = 1;
  for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MAXN 10000010
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b;
	cin>>a>>b;
	if(a<=5) cout<<'0'<<endl;
	else if(a<=12) cout<<b/2<<endl;
	else cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん
（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。
今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、
そこでしこたま酒を飲んでからやりはじめたんや。
3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。
しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。
浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、
先に兄ちゃんがわしの口に糞をドバーっと出して来た。
それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、
3人で出した糞を手で掬いながらお互いの体にぬりあったり、
糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。
しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。
浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると
けつの穴が糞と小便でずるずるして気持ちが良い。
にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。
糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。
それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、
糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。
やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。
ああ～～早く糞まみれになろうぜ。
岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や
糞まみれでやりたいやつ、至急、メールくれや。
土方姿のまま浣腸して、糞だらけでやろうや。
*/

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Main m = new Main();
    }
    
    public Main(){
        Scanner s = new Scanner(System.in);
        
        System.out.println("" + s.next().charAt(0) + s.next().charAt(1) + s.next().charAt(2));
    }
    
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[200000];
deque<int> q;

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	inc(i, n) {
		if(i % 2 == 0) { q.push_back(a[i]); }
		else { q.push_front(a[i]); }
	}
	
	if(n % 2 == 0) {
		inc(i, n) { cout << (i == 0 ? "" : " ") << q[i]; }
	} else {
		dec(i, n) { cout << (i == n - 1 ? "" : " ") << q[i]; }
	}
	
	return 0;
}


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

int main(){
  int N;cin>>N;
  map<ll,ll> mp;
  ll sum=0,ans=0;
  rep(i,N){
    ll a; cin>>a;
    sum+=a;
    if(sum==0) ans++;
    mp[sum]++;
  }
  for(auto m:mp){
    ans+=max(0LL,(m.second-1)*m.second/2);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12800
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}

inline void out(int x) {   
	if(x>9) out(x/10);   
	putchar(x%10+'0'); 
}   
double q[N];
char s[N];
int main(){
	int t;
	int a,b,k;
	k=read();
	a=read();
	b=read();
	rep(i,a,b){
		if(i%k==0){
			puts("OK");
			return 0;
		}
	}
	puts("NG");
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
char a[100010];
int cnt;
int main()
{
    scanf("%s",&a[1]);
    int i,n=strlen(&a[1]);
    for(i=1;i<=n;i++){
        if(a[i]!=a[i-1])
            cnt++;
    }
    printf("%d",cnt-1);
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int N = Integer.parseInt(sc.next());
        int[] A = new int[N];
        for (int i = 0; i < N; i++ ){
            A[i] = Integer.parseInt(sc.next()) - 1;
        }
        int B[] = new int[N];
        for (int i= 0; i < N; i++){
            B[i] = Integer.parseInt(sc.next());
        }
        int C[] = new int[N-1];
        for (int i=0; i<N-1; i++){
            C[i] = Integer.parseInt(sc.next());
        }

        int point = B[A[0]]; //最初の1食目はその料理の満足度のみ
        for (int i = 1; i < N; i++){
            point += B[A[i]];
            if (A[i] == A[i-1] + 1){
                point += C[A[i-1]];
            }
        }
        out.println(point);

        //テンプレ
        sc.close();
        out.flush();
    }
}

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

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var min = long.MaxValue;
        long left = 0;
        long right = A.Sum();
        for (int i = 0; i < N - 1; i++)
        {
            left += A[i];
            right -= A[i];
            var cost = Math.Abs(left - right);
            min = Math.Min(min, cost);
        }

        Console.WriteLine(min);
    }
}

Measured memory_bytes: 37200
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int L[105];
int X;
int main(){
    cin >> N >> X;
    for(int i=1;i<=N;i++)cin >> L[i];
    for(int i=1;i<=N;i++)L[i]+=L[i-1];
    int ans = 0;
    for(int i=0;i<=N;i++){
        if(L[i]<=X)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
import math
c_div = 0
d_div = 0
if a % c == 0:
    c_div = max(0, 1 + ((b - (b % c)) - a) // c )
else:
    c_div = max(0, 1 + ((b - (b % c)) - (a + (c - a % c))) // c )
if a % d == 0:
    d_div = max(0, 1 + ((b - (b % d)) - a) // d )
else:
    d_div = max(0, 1 + ((b - (b % d)) - (a + (d - a % d))) // d )
gcd_input = c * d // math.gcd(c, d)
if a % gcd_input == 0:
    c_d_div = max(0, 1 + ((b - (b % gcd_input)) - a) // gcd_input )
else: 
    c_d_div = max(0, 1 + ((b - (b % gcd_input)) - (a + (gcd_input - a % gcd_input))) // gcd_input )
print(b - a + 1 - d_div - c_div + c_d_div)

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

int x[101];
int main() {
	int n; cin >> n;
	int k; cin >> k;
	for (int i=0; i<n; ++i) {
		cin >> x[i];
	}
	
	int ans = 0;

	for (int i=0; i<n; ++i) {
		ans += 2*min(x[i],k-x[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

  vector<int> a(n);
  rep(i,0,n-1) cin >> a[i];

  deque<int> b;
  if (n % 2 == 0) {
    rep(i,0,n-1) {
      i % 2 == 0 ? b.push_back(a[i]) : b.push_front(a[i]);
    } 
  } else {
    rep(i,0,n-1) {
      i % 2 == 0 ? b.push_front(a[i]) : b.push_back(a[i]);
    }
  }

  for (auto i : b) cout << i << ' ';
  return 0;
}


Measured memory_bytes: 4856