akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int a[3][3];
bool c[3][3];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  rep(i,3) {
    rep(j,3) {
      cin >> a[i][j];
    }
  }
  int n;
  cin>>n;
  vector<int> b(n);
  memset(c,false,sizeof(c));
  rep(i,n)cin>>b[i];
  rep(i,n) {
    rep(j,3) {
      rep(k,3) {
	if(b[i]==a[j][k]) {
	  c[j][k]=true;
	}
      }
    }
  }
  // tate
  rep(i,3) {
    if(c[i][0]&&c[i][1]&&c[i][2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  // yoko
  rep(i,3) {
    if(c[0][i]&&c[1][i]&&c[2][i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(c[0][0]&&c[1][1]&&c[2][2]) {
    cout << "Yes" << endl;
    return 0;
  }
  if(c[0][2]&&c[1][1]&&c[2][0]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map( int, input().split() )
a = list( map( int, input().split() ) )

# 以下カンニング
for _ in range( min( k, 41 ) ): # 41 ~ log( 2 * 10 ** 5 )
    b = [ 0 ] * n

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = b

print( " ".join( list( map( str, a ) ) ) )

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

int main()
{
    int n;
    cin >> n;
    set<int> hon{2, 4, 5, 7, 9};
    set<int> pon{0, 1, 6, 8};
    set<int> bon{3};
    
    n %= 10;
    if (hon.count(n)) cout << "hon" << endl;
    if (pon.count(n)) cout << "pon" << endl;
    if (bon.count(n)) cout << "bon" << endl;
    return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL N, M;
  cin >> N >> M;
  LL minL = 0;
  LL minR = 10000000;
  REP(i,M){
    LL L, R;
    cin>>L>>R;
    minL = max(L, minL);
    minR = min(R, minR);
  }
  LL cnt = 0;
  FOR(i, minL, minR + 1){
    cnt++;
  }
  cout   << cnt << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
p = 10**9+7
a=[1] * (n+1)
for i in range(m):
  a[int(input())] =0

dp = [0] * (n+1)
dp[0]=1
dp[1]=1 if a[1] else 0
for i in range(2,n+1):
  dp[i] = a[i] * (dp[i-2]*a[i-2] + dp[i-1]*a[i-1]) % p
print(dp[n]%p)

Measured memory_bytes: 13496
import java.util.*;

public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int m = sc.nextInt();
            if( n == 0 && m == 0){
                break;
            }
            int[] taro = new int[n];
            int[] hana = new int[m];
            for(int i = 0; i < n; i++){
                taro[i] = sc.nextInt();
            }
            for(int i = 0; i < m; i++){
                hana[i] = sc.nextInt();
            }
            int sum_t = 0;
            for(int t: taro){
                sum_t += t;
            }
            int sum_h = 0;
            for(int h: hana){
                sum_h += h;
            }
            int diff = sum_t - sum_h;            
            String ans = "-1";
            for(int i = 0; i < n; i++){
                for(int ii = 0; ii < m; ii++){
                    if((taro[i] - hana[ii]) * 2 == diff){
                        ans = taro[i] + " " + hana[ii];
                        break;
                    }
                }
                if(ans != "-1"){
                    break;
                }
            }
            System.out.println(ans);
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 21040
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
#include <bitset>
#include <string>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)


ll modpow(ll x, ll n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        ll h = modpow(x, n / 2);
        return h * h % MOD;
    } else {
        return x * modpow(x, n - 1) % MOD;
    }
}

int gcd(int a,int b)  {
	if (a%b==0)  return(b);
	else return(gcd(b,a%b));
}

int main() {
    int N, K; cin >> N >> K;
    int per_one = N / K;
    int rest = N - per_one*K;
    if(rest)  per_one=1;
    else  per_one=0;

    cout << per_one << endl;

    return 0;
}


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

int main(){
	int n, x;
	cin >> n >> x;
	int a[100];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int count = 0;
	sort(a, a + n);
	for (int i = 0; i < n; ++i) {
		if (x >= a[i]) {
			x -= a[i];
			count++;
		}
	}
	if (count == n) {
		if (x == 0) cout << count << endl;
		else cout << count - 1 << endl;
	}
	else if (count != 0) cout << count << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
loop do
  h, w = gets.chomp.split(/\s/).map(&:to_i)
  break if h == 0 && w == 0
  h.times do |i|
    puts i % 2 == 0 ? ("#." * w)[0, w] : (".#" * w)[0, w]
  end
  puts ''
end

Measured memory_bytes: 8924
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, X;
	cin >> N >> X;
	vector<long long>P(N+1);
	vector<long long>B(N+1); 
	vector<long long>S(N + 1);
	P[0] = 1;
	B[0] = 0;
	S[0] = 1;
	for (int n = 0;n<N;++n) {
		P[n + 1] = P[n] * 2 + 1;
		B[n + 1] = B[n] * 2 + 2;
		S[n + 1] = S[n] * 2 + 3;
	}
	long long ans = 0;
	for (int n = N;n>=0;--n) {
		if (X >= 1) {
			X--;
		}
		else {
			continue;
		}
		if (X>=S[n-1]) {
			X -= S[n - 1];
			ans += P[n - 1];
		}
		else {
			continue;
		}
		if (X>=1) {
			X--;
			ans++;
		}
		else {
			continue;
		}

		if (X >= S[n - 1]) {
			X -= S[n - 1];
			ans += P[n - 1];
		}
		else {
			continue;
		}

		if (X >= 1) {
			X--;
		}
		else {
			continue;
		}
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3644
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Libra
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int ab = a + b, cd = c + d;
  if (ab > cd) puts("Left");
  else if (ab < cd) puts("Right");
  else puts("Balanced");
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
#define mp make_pair
#define pb push_back
using namespace std;

const lli mod = 1e9 + 7;

lli power(lli x, lli y) {
    // x %= mod;
    if (y == 0) return 1;
    // return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2)) % mod;
    return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2));
}

vector <long long int> primeNumbers;

void SieveOfEratosthenes(int n){
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++){
      if (prime[p]){
        primeNumbers.push_back(p);
      }
    }        
}

#define MAXN 100005
// vector < vector < int >  > v(MAXN);
// int visit[MAXN];
// int d[MAXN];
// int deg[MAXN];

// void dfs(int index, int parent){
//   visit[index] = 1;
//   for(int i = 0;i<v[parent].size();i++){
//     int node = v[parent][i];
//     if(visit[node]) continue;
//     else if (!binary_search(v[index].begin(),v[index].end(),node)){
//       visit[node] = 1;
//       dfs(node,index);
//     }
//   }
// }
void pre(){
}

void solve(){
  int n;
  cin>>n;
  long long int a[n];
  for(int i = 0;i<n;i++) cin>>a[i];

  long long int sum[n+1] = {0};
  for(int i = 1;i<=n;i++){
    sum[i] = sum[i-1] + a[i-1];
  }

  long long int dp[n+1][n+1];
  for(int i = 0;i<=n;i++){
    for(int j = 0;j<=n;j++){
      dp[i][j] = 10000000000000;
    }
  }
  for(int i = 0;i<=n;i++){
    dp[i][i] = 0;
  }
  // memset(cost,0,sizeof(dp));
  // int left[n+1][n+1];
  // memset(left,0,sizeof(dp));
  // for(int i = 0;i<=n;i++) left[i][i] = a[i];

  for(int size = 2;size<=n;size++){
    for(int left = 1;left<=n-size+1;left++){
      int right = left + size - 1;
      for(int k = left;k<right;k++){
        dp[left][right] = min(dp[left][right],dp[left][k] + dp[k+1][right] + sum[right] - sum[left] + a[left-1]);
      }
    }
  }

  cout<<dp[1][n];
}
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 
  int t;
  // cin>>t;
  // scanf("%d",&t);
  t = 1;
  pre();
  while(t--){
    // cout<<
    solve();
 
    if(t>0){
      cout<<endl;
      // printf("\n");
    } 
  }
 
 
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
  return 0;
}


Measured memory_bytes: 4864
/*
  第4回ユニリタプログラミングコンテスト～練習サイト～
  C言語用
  ファイル名 qA.c
  作成者 228 金子幸裕 2017/06/14 17:30
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

int main( void )
{
    char nc;

    scanf( "%c" , &nc );

    if ( ( nc == 'a' ) ||
         ( nc == 'i' ) ||
         ( nc == 'u' ) ||
         ( nc == 'e' ) ||
         ( nc == 'o' ) )
    {
        printf("vowel");
    }
    else
    {
        printf("consonant");
    }


    printf("\n");

    return ( 0 );

}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int mx = max({A, B, C});
    int sub;
    if(mx == A) sub = (A - B) + (A - C);
    else if(mx == B) sub = (B - A) + (B - C);
    else sub = (C - A) + (C - B);
    int cnt = 0;
    if(sub % 2 == 0){
        cnt = sub / 2;
    }else{
        sub++;
        cnt = 1 + sub / 2;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b, d, r, f;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (r * 100000) / b;
	cout << d << ' ' << r << ' ' << d << '.' << f << endl;
}


Measured memory_bytes: 3136
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
//ll n, a, b;
//ld ;
string s;

bool allSame(char c1, char c2, char c3, char c4){
  return (c1==c2)&&(c1==c3)&&(c1==c4);
}
 
int main() {
  cin >> s;
  ll n = s.length();
  ll nl = (n-1)/2;
  bool isStrong = true;
  for(ll i=0; i<(nl+1)/2; i++){
    //cout << s[i] << s[((n-1)/2)-1-i]<< s[((n-1)/2)+1+i] << s[n-i-1] << endl;
    isStrong = isStrong && allSame(s[i],s[nl-1-i],s[nl+1+i],s[n-i-1]);
    if(!isStrong){
      break;
    }
  }
  yorn(isStrong);
  return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int N;
int X[101010], L[101010];
pair<int, int> R[101010];

int main()
{
    cin >> N;
    rep(i, 0, N)
    {
        cin >> X[i] >> L[i];
        R[i] = make_pair(X[i] + L[i], i);
    }
    sort(R, R + N);

    int cnt = 0;
    int range = 0 - inf;
    for (int i = 0; i < N; i++)
    {
        int j = R[i].second;
        if (X[j] - L[j] >= range)
        {
            range = X[j] + L[j];
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

using namespace std;

signed main(){
    bool grey, brown, green, lightblue, blue, yellow, orange, red;
    grey = brown = green = lightblue = blue = yellow = orange = red = false;
    int N;
    int special = 0;
    cin >> N;
    for (int j = 0;j < N; j++)
    {
        int i;
        cin >> i;
        if (i  < 400) {grey = true;}
        else if (i  < 800) {brown = true;}
        else if (i  < 1200) {green= true;}
        else if (i  < 1600) {lightblue = true;}
        else if (i  < 2000) {blue = true;}
        else if (i  < 2400) {yellow = true;}
        else if (i  < 2800) {orange = true;}
        else if (i  < 3200) {red = true;}
        else  special++;
    }

    int color = 0;
        if (grey) color++;
        if (brown) color++;
        if (green) color++;
        if (lightblue) color++;
        if (blue) color++;
        if (yellow) color++;
        if (orange) color++;
        if (red) color++;

    int min,max;
    if (color == 0){
        if (special >0){ 
            min = 1;
        } else {
            min = 0;
        }
    } else {
        min = color;
     //   if ( min >= 8 ) min = 8;
    }
    max = (color + special);
    //if (max >= 8) max = 8;
    cout << min <<" "<< max;
    return 0;
}


Measured memory_bytes: 256
package main

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



func main() {
    var a,b float64
    fmt.Scan(&a,&b)
    ans := a/b
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	string S;
	cin >> S;
	int N = S.size();
	int cou = 0;
	int ans = N;
	rep(i,N){
		if(S[i] == 'T'){
			if(cou){
				--cou;
				ans -= 2;
			}
		}
		else{
			++cou;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
R,C = map(int,input().split())

maze = []
for i in range(R):
    maze.append(input())

def bfs(sx,sy,gx,gy):
    queue = []
    queue.append([sx,sy])

    visited = [ [ float("inf") for i in range(C)] for j in range(R)]
    visited[sx][sy] = 0

    while queue:
        p = queue.pop(0)

        if gx == p[0] and gy == p[1]:
            break

        for d in [[1,0],[0,1],[-1,0],[0,-1]]:
            nx = p[0] + d[0]
            ny = p[1] + d[1]

            if 0 <= nx and 0 <= ny and nx < R and ny < C and maze[nx][ny] == "." and visited[nx][ny] == float("inf"):
                queue.append([nx,ny])
                visited[nx][ny] = visited[p[0]][p[1]] + 1
    return visited[gx][gy]

k = bfs(0,0,R-1,C-1)
if k == float("inf"):
    print(-1)
    exit()
c = 0
for i in range(R):
    for j in range(C):
        if maze[i][j] == ".":
            c += 1
print(c - k - 1)


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

int main(){
    int n, i;
    long long sum = 0;
    scanf("%d", &n);
    vector<int> a(n);
    for(i = 0; i < n; i++) {
        scanf("%d", &a.at(i));
        sum += a.at(i);
    }
    vector<int>::iterator iter_max = max_element(a.begin(), a.end());
    vector<int>::iterator iter_min = min_element(a.begin(), a.end());
    printf("%d %d %lld\n", *iter_min, *iter_max, sum);
}


Measured memory_bytes: 3272
n = int(input())
p = list(map(int, input().split()))
ans = 0

for i in range(n-2):
    if p[i]<p[i+1]<p[i+2]:
        ans+=1
    if p[i]>p[i+1]>p[i+2]:
        ans+=1
        
print(ans)

Measured memory_bytes: 3060
/*
 * FileName:     koch_curve_fix
 * CreatedDate:  2020-06-11 22:24:37 +0900
 * LastModified: 2020-06-11 23:14:12 +0900
 */

#include <stdio.h>
void koch_curve(double *left,double *right,int i,int n){
    if(i==n){
        return ;
    }
    double left_next[]={2.0*(left[0])/3.0+right[0]/3.0,2.0*(left[1])/3.0+right[1]/3.0};
    double right_next[]={left[0]/3.0+2.0*right[0]/3.0,(left[1])/3.0+2.0*right[1]/3.0};
    double new_node[]={(right_next[0]-left_next[0]-1.73205081*(right_next[1]-left_next[1]))/2.0+left_next[0],(1.73205081*(right_next[0]-left_next[0])+right_next[1]-left_next[1])/2.0+left_next[1]};
    koch_curve(left,left_next,i+1,n);
    printf("%lf %lf\n",left_next[0],left_next[1]);
    koch_curve(left_next,new_node,i+1,n);
    printf("%lf %lf\n",new_node[0],new_node[1]);
    koch_curve(new_node,right_next,i+1,n);
    printf("%lf %lf\n",right_next[0],right_next[1]);
    koch_curve(right_next,right,i+1,n);
}

int main(void){
    int n;scanf("%d",&n);
    double left[]={0,0},right[]={100.0,0};
    printf("%lf %lf\n",left[0],left[1]);
    koch_curve(left,right,0,n);
    printf("%lf %lf\n",right[0],right[1]);
    return 0;
}



Measured memory_bytes: 2028
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int n, ans, a;
bool flag;
inline int read()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') {x = (x << 3) + (x << 1) + c - '0'; c = getchar();}
	return f * x;
}
int main()
{
	n = read();
	for (int i = 1; i <= n; ++i)
	{
		a = read();
		flag = true;
		for (int j = 2; j <= sqrt(a); ++j)
			if (a % j == 0)
			{
				flag = false;
				break;
			}
		if (flag) ans ++;
	}
	cout << ans << endl;
	return 0;
}



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

d = {(i, j): 0 for i in range(1, 10) for j in range(1, 10)}

for i in range(1, N + 1):
    S = str(i)
    a, b = int(S[0]), int(S[-1])
    if a == 0 or b == 0:
        continue
    d[(a, b)] += 1

res = 0
for i in range(1, 10):
    for j in range(1, 10):
        res += d[(i, j)] * d[(j, i)]

print(res)


Measured memory_bytes: 3064
import java.util.Scanner;

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

		while (true) {
			int n = scan.nextInt();
			if(n==0)break;
			int[] a = new int[100];
			int min = 1000;
			int max = 0;
			int sum = 0;
			int point;

			for (int i = 0; i < n; i++) {
				a[i] = scan.nextInt();
			}

			for (int i = 0; i < n; i++) {
				sum = sum + a[i];
				if (max < a[i])
					max = a[i];
				if (min > a[i])
					min = a[i];
			}
			point = (sum - min - max) / (n - 2);
			System.out.println(point);
		}
	}
}

Measured memory_bytes: 20948
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o E.exe E.cpp 
Execute: ./E
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

vector<int> median(int arr[], int size) {
	sort(arr, arr + size); 
	vector<int> result; 

	// Case #1: size is odd. 
	if(size % 2 != 0) {
		result = {arr[size/2]}; 
		return(result); 
	}
	
	// Case #2: size is even. 
	// Return pair of numbers that are in middle and need to be averaged. 
	result = {arr[size/2-1], arr[size/2]}; 
	return(result); 
}

int main() { 	
	int N;
	int A[200000], B[200000]; 
	
	// Inputs 
	cin >> N;
	for(int i = 0; i < N; i++) { 
		cin >> A[i] >> B[i]; 
	}
	
	// Print medians (test)
	/*
	
	cout << "Median of A" << endl;
	for(int i = 0; i < median_A.size(); i++)
		cout << median_A.at(i) << " "; 
	cout << endl; 
	
	cout << "Median of B" << endl; 
	for(int i = 0; i < median_B.size(); i++)
		cout << median_B.at(i) << " "; 
	cout << endl; 
	*/ 
	
	// Calculate result
	vector<int> median_A = median(A, N); 
	vector<int> median_B = median(B, N); 
	int result; 
	if(N % 2 != 0) { // N is odd
		result = median_B.at(0) - median_A.at(0) + 1; 		
		cout << result << endl; 
	} else { // N is even
		// (a,b) and (c,d) -> Medians are (a+b)/2 and (c+d)/2. 
		// Want all half-intervals: (c+d) - (a+b) + 1. 
		result = median_B.at(0) + median_B.at(1) - (median_A.at(0) + median_A.at(1)) + 1; 
		cout << result << endl; 
	}
	
	return 0; 
} 


Measured memory_bytes: 5156
#include<bits/stdc++.h>
#define pb push_back

typedef long long LL;

const int N=100005;
const int MOD=998244353;

int n,val[N],sg[3][N],s[3][N*2],tim[N],tmp[N*2];
std::vector<int> e[N];

int main()
{
	scanf("%d",&n);
	val[1]=1;
	for (int i=1;i<=18;i++) val[1]=(LL)val[1]*10%MOD;
	for (int i=2;i<=n;i++) val[i]=(LL)val[i-1]*val[1]%MOD;
	int mx[3]={0},now=0;
	for (int k=0;k<3;k++)
	{
		int m;scanf("%d",&m);
		for (int i=1;i<=m;i++)
		{
			int x,y;scanf("%d%d",&x,&y);
			e[x].pb(y);e[y].pb(x);
		}
		for (int i=n;i>=1;i--)
		{
			now++;
			for (int to:e[i]) if (to>i) tim[sg[k][to]]=now;
			for (sg[k][i]=0;tim[sg[k][i]]==now;sg[k][i]++);
			mx[k]=std::max(mx[k],sg[k][i]);
			e[i].clear();
		}
	}
	for (int k=0;k<3;k++)
		for (int i=1;i<=n;i++)
			(s[k][sg[k][i]]+=val[i])%=MOD;
	for (int i=0;i<=mx[0];i++)
		for (int j=0;j<=mx[1];j++)
			(tmp[i^j]+=(LL)s[0][i]*s[1][j]%MOD)%=MOD;
	int ans=0;
	for (int i=0;i<=mx[2];i++)
		(ans+=(LL)s[2][i]*tmp[i]%MOD)%=MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11136
function Main(input) {
  const tail =  Number(input) % 10
  switch(tail) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      console.log('hon')
      break
    case 0:
    case 1:
    case 6:
    case 8:
      console.log('pon')
      break
    case 3:
      console.log('bon')
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29472
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  long long sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
    sum %= MOD;
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    sum -= a[i];
    if(sum < 0) sum += MOD;
    ans += a[i] * sum;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4824
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in); 
		while(sc.hasNext()){
		String a = sc.nextLine();
			StringBuffer sb = new StringBuffer(a);
			sb.reverse();
			System.out.println(sb);
			
		}
	}
	
}

Measured memory_bytes: 15280
#include<bits/stdc++.h>
using namespace std;
int a,b,s[2019],g[10005],l;
const int M=2019;
int main(){
	scanf("%d %d",&a,&b);
	for(int i=a;i<=b;++i){
		if(s[i%M]==2)break;
		s[i%M]++;
		g[++l]=i%M;
	}
	int ans=1e9;
	for(int i=1;i<=l;++i){
		for(int o=i+1;o<=l;++o){
			ans=min(ans,g[i]*g[o]%M);
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n; string s;
set <int> r, g, b;
// main solution goes here:
void execute(int test_number)
{
    cin>>n>>s;
    for (int i=0; i<n; i++) {
        if (s[i] == 'R') r.insert(i);
        else if (s[i] == 'G') g.insert(i);
        else b.insert(i);
    }

    int ans = 0;

    for (int i:r) {
        for (int j:g) {
            ans += b.size();
            int k = min(i, j), l = max(i, j);
            if ((k+l)%2 == 0) if (b.count((k+l)/2)) ans--;
            if (b.count(2*k-l)) ans--;
            if (b.count(2*l-k)) ans--;
        }   
    }
    cout<<ans;
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

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

int main(){
	int n,d,x;
        long long int ans=0;
        int a[110];


	cin>>n;
        cin>>d>>x;
        for(int i=0; i<n; ++i) cin>>a[i];
        ans+=x;

        for(int i=0; i<n; ++i) ans+=(d-1)/a[i]+1;

	cout << ans << endl;

	return 0;
}


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 A = sc.nextInt();
			int B = sc.nextInt();
			int T = sc.nextInt();
			
			int D = T / A ;
			int ans = D * B;

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
using namespace std;
using i8t = std::int64_t;
using u8t = std::uint64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
using vu8t = std::vector<u8t>;
#include <limits>
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
#include <unordered_map>
#include <unordered_set>
template<typename Key,typename Value> using map_t=std::unordered_map<Key, Value>;
template<typename Key> using set_t=std::unordered_set<Key>;
#define F3(i,i0,iN,step) for(i8t i=i0,i##_N=iN;i<i##_N;i+=step)
#define F2(i,i0,iN) F3(i,i0,iN,1)
#define F(i,N) F3(i,0,N,1)
#define FR(i,N) for(i8t i=N;i--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}
template<typename T> struct identity { using type = T; };

int main() {
  R(X)R(Y)R(A)R(B)R(C);
  RV(p,A)RV(q,B)RV(r,C);
  std::sort(p.begin(),p.end(),[](i8t const& a,i8t const& b)->bool{return a>b;});
  std::sort(q.begin(),q.end(),[](i8t const& a,i8t const& b)->bool{return a>b;});
  std::sort(r.begin(),r.end(),[](i8t const& a,i8t const& b)->bool{return a>b;});

  i8t ip=0,iq=0,ir=0;
  i8t x=0,y=0,t=0;

  i8t ans=0;
  while(t<X+Y){
    auto pp=x<X&&ip<A?p[ip]:0;
    auto qq=y<Y&&iq<B?q[iq]:0;
    auto rr=ir<C?r[ir]:0;
    //cerr<<pp<<" "<<qq<<" "<<rr<<endl;
    if(pp>qq&&pp>=rr){
      ans+=p[ip++];
      x++;t++;
    }else if(qq>=rr){
      ans+=q[iq++];
      y++;t++;
    }else{
      ans+=r[ir++];
      t++;
    }
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int p,q;
	p = a/d;
	q = c/b;
	int r,s;
	if (a%d==0)
	{
		r=p;
	}
	else{
		r=p+1;
	}
	if(c%b==0){
		s=q;
	}
	else{
		s=q+1;
	}
	if(r>=s){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		while(true) {
			int n = sc.nextInt();

			if(n == 0) break;

			int s[] = new int[n];
			double sum = 0;
			double ave;
			double sumb = 0;  //分散の合計
			//int hens;  //標準偏差

			for(int i = 0; i < n; i++) {
				s[i] =  sc.nextInt();
				sum += s[i];
			}

			ave = sum / n;

			for(int i = 0; i < n; i++) {
				sumb += (ave - s[i]) * (ave - s[i]);
			}

			System.out.println(Math.sqrt(sumb / n));
		}
	}

}



Measured memory_bytes: 31080
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  int a[n-1],ans[n];
  for(int i=0;i<n;i++)ans[i]=0;
  for(int i=0;i<n-1;i++){
    cin >> a[i];
    ans[a[i]-1]++;
  }
  for(int i=0;i<n;i++)cout << ans[i] <<endl;
  
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

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

  sort(a.begin(),a.end());
  int left = -1, right = n;
  while(right - left > 1){
    int mid = (left + right) / 2;
    vector<int> dp(K+1, 0);
    dp[0] = 1;
    for(int j = 0; j < n; j++){
      if(j == mid) continue;
      for(int k = K-1; k >= 0; k--){
        dp[min(K, k + a[j])] |= dp[k];
      }
    }
    int cnt = 0;
    for(int i = max(0LL, K-a[mid]); i < K; i++) cnt += dp[i];
    (cnt <= 0 ? left : right) = mid;
  }
  cout << right << endl;

  return 0;
}


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

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

class Prime {
  vector<bool> is_prime;
  int n;
public:
  Prime(int n) : n(n) {
    is_prime.resize(n+1,true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
      if(is_prime[i]){
        for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
      }
    }
  }
  bool operator[](const int &k) const {
    return is_prime[k];
  }
};

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll g = a[0];
  ll m = 1;
  vector<ll> b;
  rep(i,n) {
    g = gcd(g,a[i]);
    m = max(m,a[i]);  
    if(a[i] != 1) b.push_back(a[i]);
  }
  Prime prime(m);
  ll nb = (ll)b.size();
  int sz = 0;
  for(int i = 2; i <= m; i++) if(prime[i]) sz++;
  if(nb > sz) {
    if(g == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
  }
  bool f = true;
  vector<ll> v(MAX);
  rep(i,nb) {
    for(ll j = 2; j*j <= b[i]; j++) {
      if(b[i] % j == 0) v[j]++;
      while(b[i] % j == 0) {
        b[i] /= j;
      }
    }
    if(b[i] > 1) v[b[i]]++;
  } 
  for(int i = 2; i < MAX; i++) if(v[i] >= 2) f = false;
  if(f) cout << "pairwise coprime" << endl;
  else if(g == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
  return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  char a[n][m];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  int count=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(a[i][j]=='#'){
        count++;
      }
    }
  }
  cout << (count+1==n+m?"Possible":"Impossible") << endl;
}
    

Measured memory_bytes: 256
import java.util.*;

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 count=0,point=0;
	while(point < c){
	    count++;
	    if(count%7==0){
		point+=b;
	    }
	    point+=a;
	}
	System.out.println(count);
    }
}


Measured memory_bytes: 26368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static int max = 0;
    static void Main(string[] args)
    {
        int[] arr = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int turn = 0;
        while (true)
        {
            turn++;
            arr[2] -= arr[1];
            if (arr[2] <= 0) break;
            turn++;
            arr[0] -= arr[3];
            if (arr[0] <= 0) break;
        }
        Console.WriteLine(turn%2==1 ? "Yes" : "No");


    }


}



Measured memory_bytes: 18800
import numpy as np
n=int(input())
a=list(map(int,input().split()))
sign=[1 if i%2==0 else -1 for i in range(n)]
a=np.array(a)
sign=np.array(sign)
plusA=a*sign
# minusA=a*sign*-1
ruisekiPlusA=[0 for i in range(n+1)]
for i in range(1,n+1):
    ruisekiPlusA[i]=ruisekiPlusA[i-1]+plusA[i-1]

# print(plusA,minusA)
for i in range(n):
    if i%2==0:
        # print(minusA[:i],plusA[i:])
        # print(np.sum(minusA[:i])+np.sum(plusA[i:]),end=' ')
        print(ruisekiPlusA[n]-2*ruisekiPlusA[i],end=' ')
    else:
        # print(plusA[:i],minusA[i:])
        # print(np.sum(plusA[:i])+np.sum(minusA[i:]),end=' ')
        print(2*ruisekiPlusA[i]-ruisekiPlusA[n],end=' ')

Measured memory_bytes: 23120
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
c = [LIST() for _ in range(10)]
A = [LIST() for _ in range(H)]

#ワーシャルフロイド法  注意 PyPy非対応!!!!
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

graph = csr_matrix(c) #隣接行列からcsr行列をつくる
c = floyd_warshall(graph, directed=True) #無向の場合directed=True
#dist_matrixの中身はfloatになっているので注意！
	

#for i in range(10):
#	print(c[i])

import numpy as np
#距離
def distance(p1, p2):
	p1 = np.array(p1)
	p2 = np.array(p2) 
	return np.linalg.norm(p1-p2)
	

ans = 0
for i in range(H):
	for x in A[i]:
		if x == 1 or x == -1:
			continue
		else:
			ans += c[x][1]

print(int(ans))



Measured memory_bytes: 21560
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
#include <queue>
#include <type_traits>
#include<cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    int n=1e9;
    n = min(x+y,n);
    n = min(y+z,n);
    n = min(x+z,n);
    cout << n <<endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int num[N];
bool vis[N];
char s[5];
int main() {
	int n,m,id,a=0,b=0;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++) {
		scanf("%d%s",&id,s);
		if(vis[id]) continue;
		if(s[0]=='A') a++,b+=num[id],vis[id]=true;
		else num[id]++;
	}
	printf("%d %d\n",a,b);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

using namespace std;

const int N = int(10e5 + 5);

int main() {

	FIO
	int k; cin >> k;
	if (k%2 == 0 || k%5 == 0) {
        cout << "-1";
        exit(0);
	}
	int s = 7;
	int pos = 1;
	while (true) {
        if (s%k == 0) {
            cout << pos;
            break;
        }
        else if (pos >= k) {
            cout << "-1";
            break;
        }
        s = (s % k) * 10 + 7;
        pos++;
	}
	return 0;
}

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

int main(){
  long long n,p; cin>>n>>p;
  if(n==1)cout<<p<<endl;
  else{
  long long ans=1, a=2,b=0;
  while(a<=sqrt(p)+1){
    while(p%a==0){
      ++b;
      p/=a;
    }
    for(int i=0; i<b/n; ++i)ans*=a;
    b=0;
    ++a;
  }
  cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
#define MAX_W 100
#define MAX_H 100
char farm[MAX_W][MAX_H];
int W, H;
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
void dfs(const int& x, const int& y, const char tree)
{
	farm[x][y] = 'x';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + direction[i][0];
		int ny = y + direction[i][1];
		if (nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == tree)
		{
			dfs(nx, ny, tree);
		}
	}
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	while (cin >> H >> W, W > 0)
	{
		int res = 0;
		int x, y;
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				cin >> farm[x][y];
			}
		}
 
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				if (farm[x][y] != 'x')
				{
					dfs(x, y, farm[x][y]);
					++res;
				}
			}
		}
		cout << res << endl;
	}
 
	return 0;
}

Measured memory_bytes: 3864
#include<stdio.h>

int main(void){
int n,a,i,max,min;
long int s;
scanf("%d",&n);
scanf("%d",&a);
s=a;min=a;max=a;
for(i=1;i<n;i++){
   scanf("%d",&a);
   s=s+a;
   if(max<a){max=a;}
   if(min>a){min=a;}
}
printf("%d %d %ld\n",min,max,s);

return 0;
}



Measured memory_bytes: 2736
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int sz=(1<<21);
int dp[22][sz+5];
const int mod=1e9+7;

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
     cout.tie(0);   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     
   
   int n;
   cin>>n;
   int x;
   dp[0][0]=1;
   for(int i=1;i<=n;i++)
   {
      for(int j=1;j<=n;j++)
      {
         cin>>x;
         if(!x)
            continue;
         
         for(int k=0;k<(1<<n);k++)
         {
            if(((k>>(j-1)&1))^1)
            {
               dp[i][k|(1<<(j-1))]+=dp[i-1][k];
               dp[i][k|(1<<(j-1))]%=mod;
            }
         }
      }
   }
   cout<<dp[n][(1<<(n))-1];

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 344320
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int other = 16 - a - b;
		
		int max = Math.max(a, b);
		int min = Math.min(a, b);
		
		for(int i = 0; i < 16; i++) {
			max--;
			if(max == 0) break;
			if(min > 0) {
				min--;
			} else {
				other--;
			}
			if(max != 0 && min == 0 && other == 0) {
				System.out.println(":(");
				return;
			}
		}
		
		System.out.println("Yay!");
	}
}


Measured memory_bytes: 20564
#include<iostream>
using namespace std;
int main(){
  string s;
  int n,k;
  cin>>n>>k;
  cin>>s;
  if(s[k-1]=='A')s[k-1]='a';
    if(s[k-1]=='B')s[k-1]='b';
      if(s[k-1]=='C')s[k-1]='c';
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include<iostream>


using namespace std;

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

	int count = 0;
	for (int i = 0; i < N-2; i++) {
		if (S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') {
			count++;
		}
	}

	cout << count << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
using ll = long long int;
using namespace std;
double pi = 3.141592653589793238;

#define FOR(i,N) for(int i=0;i<N;i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

int bitcnt(int numofbitcnt) {
	int karibitcnt = 0;
	for (int i = 0; i < 32; i++) {
		if (numofbitcnt & 1 << i)karibitcnt++;
	}
	return karibitcnt;
}

double L2(double positionx, double positiony) {
	return sqrt(positionx * positionx + positiony * positiony);
}

int main() {
	cout << fixed << setprecision(8);
	int N;
	cin >> N;

	int x[8], y[8];
	FOR(i, N) {
		cin >> x[i] >> y[i];
	}
	double nbicr = 1;
	vector<int> p(8);
	FOR(i, N) {
		p[i] = i;
		nbicr *= i+1;
	}
	double ness = 0;
	do {
		
		FOR(i, N-1) {
			ness += L2(x[p[i + 1]] - x[p[i]], y[p[i + 1]] - y[p[i]]);
		}

	} while (next_permutation(p.begin(), p.begin() + N));

	ness /= nbicr;
	cout << ness << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 2000 + 10; 

inline int add(int a, int b, int mod = MOD) {
  a += b; return a >= mod ? a - mod : a;
}
inline int sub(int a, int b, int mod = MOD) {
  a -= b; return a < 0 ? a + mod : a;
}
inline int mul(int a, int b, int mod = MOD) {
  return int((long long) a * b % mod);
}
inline int power(int base, long long ex, int mod = MOD) {
  int res = 1;
  for (; ex > 0; ex >>= 1) {
    if (ex & 1) res = mul(res, base, mod);
    base = mul(base, base, mod);
  }
  return res;
}
inline int inv(int a, int mod = MOD) {
  return power(a, mod - 2, mod);
}
inline int mdiv(int a, int b, int mod = MOD) {
  return mul(a, power(b, mod - 2,  mod));
}
inline void adds(int &a, int b, int mod = MOD) {
  a += b; if (a >= mod) a -= mod;
}
inline void subs(int &a, int b, int mod = MOD) {
  a -= b; if (a < 0) a += mod;
}
inline void muls(int &a, int b, int mod = MOD) {
  a = int((long long) a * b % mod);
}
inline void mdivs(int &a, int b, int mod = MOD) {
  a = mdiv(a, b, mod);
}
vector<int> fact,ifact;
void prep_fact(int mx = 1e6 + 40) {
  fact.assign(mx,0);
  ifact.assign(mx,0);
  fact[0] = 1;
  for (int i = 1; i < mx; ++i) fact[i] = mul(i, fact[i - 1]);
  ifact[mx - 1] = inv(fact[mx - 1]);
  for (int i = mx - 1; i > 0; --i) ifact[i - 1] = mul(i, ifact[i]);
}
inline int ncr(int n, int r) {
  if (n < r || r < 0 || n < 0) return 0;
  return mul(fact[n], mul(ifact[n - r], ifact[r]));
}

int dp[N];

int dfs(int x){
   if(x < 0) return 0;
   if(x == 0){
      return 1;
   }
   if(dp[x] != -1) return dp[x];
   dp[x] = 0;
   for(int i = 3; i <= N; ++i){
      adds(dp[x],dfs(x-i));
   }
   return dp[x];
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int s;
   cin >> s;
   memset(dp,-1,sizeof dp);
   cout << dfs(s) << '\n';
   return 0;
} 

Measured memory_bytes: 3696
#include <iostream>
using namespace std;
 
int main()
{
  int a,b=0;
  char op=0;
  do{
      cin>>a>>op>>b;
      switch(op){
          case '+':
          cout<<a+b<<endl;
          break;
          case'-':
          cout<<a-b<<endl;
          break;
          case '*':
          cout<<a*b<<endl;
          break;
          case'/':
          cout<<a/b<<endl;
          break;
        default:
        break;
      }
  }while(op!='?');
  return 0;
   
}

Measured memory_bytes: 3120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
 
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for(int i = 0; i < n; i++)
#define LL long long
const int mod = 1e9 + 7;
const int inf = 1e9;


LL pn, qn;
LL n, k;
LL a[200005];
vector<LL> p, q;

LL get1(LL x) {
    LL s = 0;
    for(int i = 0, j = qn - 1; i < (int)p.size(); i++) {
        while(j >= 0 && p[i] * -q[j] <= x) {
            j--;
        }
        s += (qn - j - 1);
    }
    return s;
}
LL get2(LL x) {
    LL s = 0;
    for(int i = 0, j = pn - 1; i < pn; i++) {
        while(j >= 0 && p[i] * p[j] > x) {
            j--;
        }
        s += max(0, j - i); 
    }
    for(int i = 0, j = qn - 1; i < qn; i++) {
        while(j >= 0 && q[i] * q[j] > x) {
            j--;
        }
        s += max(0, j - i); 
    }
    return s;
}

LL solve1() {
    LL l = -1e18, r = 0;
    while(l + 1 < r) {
        LL mid = (l + r) / 2;
        if(get1(mid) < k) l = mid;
        else r = mid;
    }
    if(get1(l) >= k) return l;
    else return r;
}

LL solve2() {
    k -= pn * qn;
    LL l = 0, r = 1e18;
    while(l + 1 < r) {
        LL mid = (l + r) / 2;
        if(get2(mid) < k) l = mid;
        else r = mid;
    }
    if(get2(l) >= k) return l;
    else return r;
}

int main() {
    //freopen("in", "r", stdin);
    cin >> n >> k;


    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i] < 0) q.push_back(-a[i]);
        else p.push_back(a[i]);
    }
    pn = p.size(), qn = q.size();
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    if(pn * qn >= k) {
        cout << solve1() << endl;
    }
    else {
        cout << solve2() << endl;
    }
    return 0;
}

Measured memory_bytes: 3700