akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <boost/dynamic_bitset.hpp>
using namespace std;

pair<int,int> halfAdder(int a,int b)
{
    int s = a ^ b;
    int c = a & b;
    return make_pair(s,c);
}

pair<int,int> fullAdder(int a,int b,int c)
{
    pair<int,int> sum = halfAdder(a,b);
    pair<int,int> sum_ = halfAdder(sum.first,c);
    int s = sum_.first;
    c = sum.second | sum_.second;
    return make_pair(s,c);
}

template <typename Block, typename Allocator>
boost::dynamic_bitset<Block, Allocator>
operator+(const boost::dynamic_bitset<Block, Allocator>& x,
          const boost::dynamic_bitset<Block, Allocator>& y)
{
    vector<bool> t;
    int c = 0;
    for (int i = 0; i < x.size(); i++) {
        int a = x[i];
        int b = y[i];
        pair<int,int> r = fullAdder(a,b,c);

        t.push_back(r.first);
        c = r.second;
    }
    if(c) t.push_back(1);
    boost::dynamic_bitset< > s(t.size());
    for (int i = t.size()-1; i >= 0; i--) {
        if(t[i] == 1)s.set(i);
    }
    return s;
}

vector<boost::dynamic_bitset< >> bitEnum(int bit)
{
    vector<boost::dynamic_bitset< >> c;
    boost::dynamic_bitset< > a(bit);
    boost::dynamic_bitset< > b(bit);b.set(0);
    for (int i = 0; i < pow(2,bit); i++) {
        c.push_back(a);
        a = a + b;
    }
    return c;
}

vector<vector<char>> a;
int h,w;

vector<int> slv()
{
    vector<int> e;
    vector<boost::dynamic_bitset< >> b = bitEnum(h+w-1);
    for (auto x : b) {
        vector<vector<char>> c = vector<vector<char>>(h,vector<char>(w));
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                c[i][j] = a[i][j];
            }
        }
        int i = 0,j = 0;
        for(int k = 0;k < x.size(); k++){
            try{c.at(i).at(j) = '.';}catch(...){}
            if(x[k] == 1){
                //right
                try{if(c.at(i).at(j+1) != '#')break;}catch(...){}
                j++;
            }else{
                //down
                try{if(c.at(i+1).at(j) != '#')break;}catch(...){}
                i++;
            }
        }
        //cout << x << endl;
        int d = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if(c[i][j] == '.')d++;
                //cout << c[i][j];
            }
            //cout << "" << endl;
        }
        //cout << "" << endl;
        if(d == h*w)e.push_back(0);
        else e.push_back(1);
    }
    return e;
}

int main(int argc, char const* argv[])
{
    cin>>h>>w;
    a = vector<vector<char>>(h,vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin>>a[i][j];
        }
    }

    vector<int> a = slv();
    for (auto x : a) {
        if(x == 0){cout << "Possible" << endl;return 0;}
    }
    cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 2548
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = /*1'000'000'007LL;*/ 998'244'353LL;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };



signed main(){
    /*for(int N=4; N<=5; N++){
        for(int K=3; K<=5; K++){
            bool flg = false;
            vector<int> ab, c;
            rep(i, N) ab.pb(K+i);
            rep(i, N) ab.pb(K+N+i);
            rep(i, N) c.pb(K+2*N+i);
            do{
                bool tmp = true;
                rep(i, N){
                    tmp &= (ab[2*i] + ab[2*i+1] <= c[i]);
                }
                flg |= tmp;
                if(tmp){
                    rep(i, N) cout << ab[2*i] << " " << ab[2*i+1] << " " << c[i] << endl;
                    cout << "===" << endl;
                }
            } while(next_permutation(all(ab)));
            //cout << flg << " ";
        }
        //cout << endl;
    }*/


    int N, K;
    cin >> N >> K;
    if(2*K-1 > N){
        cout << -1 << endl;
        return 0;
    }
    int a = 0;
    int b = (N-1)/2;
    rep(i, N){
        cout << K+a << " " << K+N+b << " " << K+2*N+i << endl;
        a = (a+2) % N;
        if(a == 0) a++;
        b = (b-1+N) % N;
    }
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	vector<llong> K, P;

	cin >> N;
	K.resize(N);
	P.resize(N);
	for(int i = 0; i < N; i++){
		cin >> K[i] >> P[i];
	}

	for(int i = 0; i < N; i++){
		cout << (K[i]%P[i] == 0 ?P[i] : K[i]%P[i])  << endl;
	}

	return 0;
}


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

typedef long long lint;
typedef long double louble;

#define lf '\n'

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 507 , __ = 9999999;
const int go[2][4] = {{1,0,-1,0},{0,1,0,-1}};

inline lint gcd(lint a,lint b){while(b)a%=b,swap(a,b);return a;}
inline lint lcm(lint a,lint b){return a/gcd(a,b)*b;}

int pri[__]={0},isnp[__]={0},pcnt=0;

inline void shai(int n=__-1)
{
	isnp[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(!isnp[i])pri[++pcnt]=i;
		for(int j=1;j<=pcnt && 1ll*i*pri[j]<=n;j++)
		{
			int a=i*pri[j];
			isnp[a]=1;
			if(i%pri[j]==0)break;
		}
	}
}

int n;
lint val[_][_];

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);
	
	shai();
	
	n=ty();
	if(n==2){cout<<"4 7\n23 10\n";return 0;}
	for(int i=1;i<=n;i++)
		for(int j=1,rk1,rk2;j<=n;j++)
			if((i+j)&1)rk1=(i+j+1)/2,rk2=(i-j+n+1)/2,val[i][j]=1ll*pri[rk1]*pri[rk2+n];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if((i+j+1)&1)
			{
				val[i][j]=1;
				for(int k=0;k<4;k++)
					if(val[i+go[0][k]][j+go[1][k]])val[i][j]=lcm(val[i][j],val[i+go[0][k]][j+go[1][k]]);
				val[i][j]++;
			}

	for(int i=1;i<=n;i++,cout<<lf)
		for(int j=1;j<=n;j++)
			cout<<val[i][j]<<' ';
	
	return 0;
}


Measured memory_bytes: 48128
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
	int count = 0;
	int n_500, n_100, n_50, x;
	cin >> n_500 >> n_100 >> n_50 >> x;

	rep(i, n_500+1)rep(j, n_100+1)rep(k, n_50+1)
	{
		if ((i * 500 + j * 100 + k * 50) == x) count++;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3604
fun main(args: Array<String>) {
    val N = nextInt()
    fun dfs(s: String, mx: Char) {
        if (s.length == N) println(s)
        else {
            for (c in 'a' .. mx + 1) {
                dfs(s + c, listOf(c, mx).max()!!)
            }
        }
    }
    dfs("", 'a' - 1)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())


Measured memory_bytes: 43144
#include <iostream>

using namespace std;

int n, k;
int d[11];

bool in(int x) {
  for (int i=0;i<k;i++) {
    if (x == d[i]) {
      return true;
    }
  }
  return false;
}

bool check(int x) {
  while (x > 9) {
    if (in(x % 10)) {
      return false;
    }
    x /= 10;
  }
  return !in(x);
}

void solve() {
  for (int i=n;i<10 * n;i++) {
    if (check(i)) {
      cout << i << endl;
      return;
    }
  }
}

int main() {
  cin >> n >> k;
  for (int i=0;i<k;i++) {
    cin >> d[i];
  }
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s;
	cin>>t;
	long long int diff=0;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i])
		diff++;
	}
	cout<<diff<<endl;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	REP(i, n)
	{
		set<char> st;
		st.insert(a[i]);
		st.insert(b[i]);
		st.insert(c[i]);
		ans += st.size() - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k; cin >> n >> k ;
  vector<ll> a(n);
  ll psum = 0;
  rep(i,n){
      cin >> a[i];
      if(a[i]>0){
          psum += a[i];
      }
  }
  vector<ll> sa(n+1);
  vector<ll> psa(n+1);
  sa[0] = 0;
  psa[0] = 0;
  rep(i,n){
      sa[i+1] = sa[i] + a[i];
      psa[i+1] = psa[i];
      if(a[i]>0){
          psa[i+1] += a[i];
      }
  }
  ll ans = 0;
  rep(i,n-k+1){
      ll tmp = psa[i] - psa[0] +  psa[n] - psa[i+k];
      if(sa[i+k] - sa[i]>0){
          tmp += sa[i+k] -sa[i];
      }
      ans = max(ans,tmp);
  }
  rep(i,n+1){
      cerr << sa[i] << " " ;
  }
  cerr << endl;
  rep(i,n+1){
      cerr << psa[i] << " " ;
  }
  cout << ans << endl;

}

Measured memory_bytes: 2688
// Last Change: 04/07/2019 13:32:55.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  string S;
  ll K;
  cin >> S >> K;

  ll onePos = 0;
  while (onePos < S.size() and S[onePos] == '1') {
    ++onePos;
  }

  if (onePos >= K) {
    cout << 1 << endl;
  } else {
    cout << S[onePos] << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

s=input()
t=input()
ans=0

for i in range(3):
    if s[i]==t[i]:
        ans+=1
print(ans)

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a[] = new long[n];
		for (int i = 0; i <= n-1; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		long sta, gol;
		long ans = 0;
		sta = 0;
		gol = 0;
		long nag = 0;

		if ((n != 1)&&n!=2) {
			for (int i = 0; i <= n - 2; i++) {
				if (a[i] != a[i + 1]) {

					gol = i;
					nag = gol - sta + 1;
					sta=i+1;
					if (nag % 2 == 1) {
ans++;
					}
					if(i==n-2){
						ans++;
					}
				} else if (i == n - 2 && (a[i] == a[i + 1])) {

					gol = i + 1;
					nag = gol - sta + 1;
					sta = i + 1;
					if (nag % 2 == 1) {
						ans++;
					}

				}

			}
		} else if(n==1){

			ans = 1;

		}else if(n==2){
			if(a[0]==a[1]){
				ans=0;
			}else{
				ans=2;
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    while(cin >> n, n){
        cin.ignore();
        vector<pair<int, int> > ans;
        for(int i=0; i< n; i++){
            string ss;
            getline(cin,ss);

            vector<int> v;
            while(true){
                int idx = 0;
                while(ss[idx] != ' ') idx++;
                string num = ss.substr(0, idx);
                v.push_back(stoi(num));
                if(num == ss) break;
                ss = ss.substr(idx+1);
            }
            pair<int, int> p;
            p.second = -1*v[0];
            int score = 0;
            int frame[15] = {0};
            int s[15] = {0};
            int pp[15] = {0};
            int count = 0;
            for(int i=1; i< v.size(); i++){
                if(count < 9){
                    int pin = v[i];
                    if(pin != 10){
                        i++;
                        pin += v[i];
                        if(pin == 10) s[count] = 2;
                        else s[count] = 1;
                        frame[count] = pin;
                    }
                    else {
                        s[count] = 3;
                        frame[count] = pin;
                    }
                } else {
                    int pin = v[i];
                    s[count] = 1;
                    frame[count] = pin;
                }
                pp[count] = i;
                count++;
            }
            for(int i=0; i < 12; i++){
                score += frame[i];
                for(int j=1; j < s[i]; j++){
                    score += v[pp[i]+j];
                }
            }
            p.first = score;
            ans.push_back(p);
        }
        sort(ans.rbegin(), ans.rend());
        for(int i=0; i < ans.size(); i++){
            cout << -ans[i].second << " " << ans[i].first << endl;
        }
    }
}

Measured memory_bytes: 1240
n=int(input())
a=list(map(int,input().split( )))
ans=1
for i in range(n):
    if a[i]==0:
        ans=0
        break
if ans==0:
    print(0)
else: 
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
            ans=-1
            break
    print(ans)

Measured memory_bytes: 21796
using System;
using System.IO;
using System.Collections.Generic;

namespace ABC089
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var X = ss.Next(Int);
            sw.WriteLine(X / 3);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
        static readonly Func<string, int> Int = int.Parse;
        static readonly Func<string, long> Long = long.Parse;
        static readonly Func<string, double> Double = double.Parse;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> A >> B >> C >> X;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (500 * i + 100 * j + 50 * k == X)ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main(void) {
	int N;
	scanf("%d", &N);
	int A[101000] = {0};
	for (int i = 0; i < N; i++) {
		int a;
		scanf("%d", &a);
		A[a]++;
		A[a + 1]++;
		A[a + 2]++;
	}
	int ans = 0;
	for (int i = 0; i < 101000; i++) {
		ans = max(ans, A[i]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4172
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <algorithm>
#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<int> a(n);
int ans=0;
	rep(i,m)cin >> a[i];
	rep(i,m) ans+=a[i];

	if (n-ans < 0)
		cout << -1 << endl;
	else
		cout << n-ans << endl;

	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント:
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main(){
  int A, B;
  cin >> A >> B;
  int C = B*10;
  int D = (B+1)*10;
  
  while(C < D){
    if( C*8/100 == A){
      cout << C << endl;
      return 0;
    }
    else{
      C++;
    }
  }
  
  cout << -1 << endl;
}
  
    

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

int main()
{
    std::string a, b;
    std::cin >> a >> b;

    if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}


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

int main() {
  long long a,b;
  cin>>a>>b;
  long long ans;
  long long g=__gcd(a,b);
  ans=a*b/g;
  cout<<ans<<endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext())
		{
			int n= sc.nextInt();
			if(n==0)
				return;
			int a[] = new int[8];

			for(int i=0; i<n; i++)
			{
				int x = sc.nextInt();
				if(x<10)
				{
					a[1]++;
					continue;
				}
				else if(x<20)
				{
					a[2]++;
					continue;
				}
				else if(x<30)
				{
					a[3]++;
					continue;
				}	
				else if(x<40)
				{
					a[4]++;
					continue;
				}	
				else if(x<50)
				{
					a[5]++;
					continue;
				}	
				else if(x<60)
				{
					a[6]++;
					continue;
				}	
				else
				{
					a[7]++;
					continue;
				}	
			}
			for(int i=1; i<8;i++)
				System.out.println(a[i]);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (ll i=a;i<=b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define mod 998244353
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=100000+5;
int main()
{
#ifdef ONLINE_JUDGE
    FAST;
#endif
    int n,h,w,cnt=0;
    cin>>n>>h>>w;
    lp(i,1,n)
    {
        lp(j,1,n)
        {
            if ((n-j+1)>=h&&(n-i+1)>=w)
            {
                cnt++;
            }
        }
    }
    cout<<cnt<<"\n";
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	a := io.NextInts(n)
	x := 1000
	for i := 0; i < n-1; i++ {
		if a[i+1] > a[i] {
			k := x / a[i]
			x %= a[i]
			x += k * a[i+1]
		}
	}
	io.Println(x)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextInts returns n integers from stdin
func (io *Io) NextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = io.NextInt()
	}
	return ret
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1788
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)
if x > a:
  xa = x-a
else:
  xa = a-x
if x > b:
  xb = x-b
else:
  xb = b-x
if xa > xb:
  print("B")
else:
  print("A")

Measured memory_bytes: 3060
#include <iostream>
    #include <string>
    #include <vector>
    #include <algorithm>
    #include <set>
    #include <map>
    #include <cmath>
     
    using namespace std;
    using ll = long long;
     
    int main(){
        int r;
        cin >> r;
        cout << 2*(double)r*3.1415926535 << endl;
    }

Measured memory_bytes: 3788
#include<stdio.h>
#include<string.h>
int main(void){
	char moji[10000];
	int len,i;
	scanf("%s",moji);
	len=strlen(moji);
	for(i=0;i<len;i++){
		if(moji[i]<=67){
			moji[i]=moji[i]-65+88;
		}
		else {
			moji[i]-=3;
		}
	}
	printf("%s\n",moji);
	return 0;
}

Measured memory_bytes: 956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+30;
int a,b,c,d,e,f;
int main(){
    cin >> a >> b >> c >> d >> e;
    f=(c-a)*60+(d-b);
    cout << f-e << endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int n;

bool check(vs& fld)
{
	for (auto i : fld)for (auto j : i)
	{
		if (j == '#') return false;
	}
	return true;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> n;
	vs fld(n);
	for (auto &i : fld) cin >> i;
	if (check(fld))
	{
		cout << -1 << endl;
		return 0;
	}
	int ok = 0;
	REP(j, n)
	{
		bool f = true;
		REP(i, n)
		{
			if (fld[i][j] == '.') f = false;
		}
		if (f) ok++;
	}
	int hor = 11111;
	REP(i, n)
	{
		int tmp = 0;
		int f = 0;
		REP(j, n)
		{
			if (fld[i][j] == '#') continue;
			tmp++;
			bool ff = true;
			REP(k, n)
			{
				if (fld[k][i] == '#') ff = false;
			}
			if (ff) f = 1;
		}
		tmp += f;
		chmin(hor, tmp);
	}
	cout << hor + n - ok << endl;
	return 0;
}

Measured memory_bytes: 512
import Data.Array
import qualified Data.Map.Strict as Map

main = do
  h:w:_ <- map read . words <$> getLine :: IO [Int]
  ss <- lines <$> getContents :: IO [String]
  putStrLn $ show $ solveAll $ readAsMatrix h w ss

readAsMatrix :: Int -> Int -> [String] -> Array Int (Array Int Bool)
readAsMatrix n m ss = array (1, n) $ zip [1..n] $ map line ss
    where line s = array (1, m) $ zip [1..m] $ map figToInt s
          figToInt '#' = False
          figToInt '.' = True

solveAll :: Array Int (Array Int Bool) -> Int
solveAll maze = maximum $ let n = length $ indices maze
                              m = length $ indices (maze ! 1)
                          in [ solve n m (i, j) maze | i <- indices maze, j <- indices (maze ! i), (maze ! i) ! j ]

solve :: Int -> Int -> (Int, Int) -> Array Int (Array Int Bool) -> Int
solve n m (i,j) maze = Map.foldr max 0 $ bfs [((i, j), 0)] Map.empty
    where bfs :: [((Int, Int), Int)] -> Map.Map (Int, Int) Int -> Map.Map (Int, Int) Int
          bfs [] a = a
          bfs (((i,j),d):q) a = case  Map.lookup (i, j) a of
                                  Just _ -> bfs q a
                                  Nothing -> bfs (q ++ r) $ Map.insert (i, j) d a
                                      where r = [ ((y, x), d + 1) | (y,x) <- around (i, j), (maze ! y) ! x, Map.lookup (y, x) a == Nothing ]
                                            around (i, j) = [ (y, x) | (y,x) <- [(i+1, j), (i, j-1), (i-1, j), (i, j+1)], 0 < y, y <= n, 0 < x, x <= m ]


Measured memory_bytes: 2300
#include <stdio.h>
int main()
{
	int a;
	int b;
	int c;
	int s=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a!=b&&a!=c&&b!=c)
	{
		printf("3");
	}
	if(a==b||a==c||b==c)
	{
		if(a==b&&a==c&&b==c)
		{
			printf("1");
			
			return 0;
		}
		printf("2");
	}
}		
	

Measured memory_bytes: 128
#include <vector>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

double solve (double t1, double v1, double t2, double v2, double vmax) {
	if (v1>vmax || v2 > vmax)
		return -inf;
	double vmax_theory = min(v1,v2) + (t2-t1+abs(v2-v1))/2.0;
	double area1 = (vmax_theory-min(v1,v2))*(vmax_theory-min(v1,v2));
	double area2 = (abs(v1-v2)*abs(v1-v2))/2.0;
	double area3 = (t2-t1)*min(v1,v2);
	if (vmax_theory < vmax) {
		return area1-area2+area3;
	} else {
		double area4 = (vmax_theory-vmax)*(vmax_theory-vmax);
		return area1-area2+area3-area4;
	}
}

double ts[105]; double vs[105];
double dp[105][105];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int N;
	cin >> N;
	for(int i=1;i<=N;++i) {
		cin >> ts[i];
		ts[i] += ts[i-1];
	}
	for(int i=1;i<=N;++i) {
		cin >> vs[i];
	}
	for(int i=0;i<105;++i) 
		for(int j=0;j<105;++j)
			dp[i][j] = -inf;
	dp[0][0] = 0.0;
	
	for(int t_idx=1;t_idx<=N;++t_idx) {
		for(int v1=0;v1<vs[t_idx-1]+1;++v1)
			for(int v2=0;v2<vs[t_idx]+1;++v2)
			{
				if (dp[t_idx-1][v1] < 0.0 || abs(v2-v1) > ts[t_idx] - ts[t_idx-1])
					continue;
				dp[t_idx][v2] = max(dp[t_idx][v2],
					dp[t_idx-1][v1]+solve(ts[t_idx-1],v1,ts[t_idx],v2,vs[t_idx]));
			}
	}
	cout << std::fixed << setprecision(18) << dp[N][0] << endl;

}

Measured memory_bytes: 384
def solve():
    N, A, B = list(map(int, input().split()))
    if A > B:
        print(0)
        return
    elif A == B:
        print(1)
        return
    elif N == 1:
        print(0)
        return
    else:
        print(B*(N-2)-(A*(N-2))+1)

solve()


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
X, Y, Z = map(int, input().split())

X = X - (Z*2)
cnt = 0
while (X >= Y) :
  X -= Y
  cnt += 1
  X -= Z
  
print (cnt)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const ll INF = ll(1e18)+1;
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; }

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(2000005);
 

mint f2(int n, int k) {
  return comb(n+k-1,k-1);
}
mint f(int n, int k) {
  if (n == 0 && k == 0) return 1;
  return f2(n-k,k);
}
 
int main() {
  int n, k;
  cin >> n >> k;
 
  for (int i = 1; i <= k; i++) {
    mint blue = f(k,i);
    mint red = 0;
    {
      red += f(n-k,i-1);
      red += f(n-k,i);
      red += f(n-k,i);
      red += f(n-k,i+1);
    }
    mint ans = blue*red;
    printf("%lld\n", ans.x);
  }
  return 0;
}


Measured memory_bytes: 31488
s, t = raw_input(), raw_input()
def check(a,b):
	if len(a) != len(b): return False

	for u,v in zip(a,b):
		if u != v and u != '?':
			return False
	return True
cand = -1
for i in range(len(s)):
	if check(s[i:i + len(t)],t): cand = i

print (s[:cand].replace('?', 'a') + t + s[cand+len(t):].replace('?','a')) if cand != -1 else 'UNRESTORABLE'


Measured memory_bytes: 64580
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    double x[10];
    string u[10];
    for(int i=0;i<N;i++)
        cin >> x[i] >> u[i];
    
    double ans = 0;
    for(int i=0;i<N;i++){
        if(u[i] == "JPY")
            ans += x[i];
        else
            ans += 380000.0 * x[i];        
    }

    printf("%.5lf", ans);
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N,M = inputMap()
	ansrs_AC = [0 for i in range(N)]
	ansrs_WA = [0 for i in range(N)]
	ans1 = 0
	ans2 = 0
	for i in range(M):
		inp = input()
		inp = inp[:-1]
		p, S = inp.split(" ")
		pp = int(p)
		if S == "AC":
			if ansrs_AC[pp-1] == 1:
				continue
			else:
				ansrs_AC[pp-1] = 1
		else:
			if ansrs_AC[pp-1] == 1:
				continue
			else:
				ansrs_WA[pp-1] += 1

	for i in range(N):
		if ansrs_AC[i] == 1:
			ans1 += 1
			ans2 += ansrs_WA[i]
	print("{} {}".format(ans1, ans2))

if __name__ == "__main__":
	main()


Measured memory_bytes: 47152
#include <stdio.h>
int size[101],g[101][101],x[101], y[101], k, d;
void dfs(int z){
  int i;
  x[z] = d++;
  for(i=1;i<=size[z];i++) if(!x[g[z][i]]) dfs(g[z][i]);
  y[z] = d++;
}
 
main(){
  int i, j, a;
  d=1;
  scanf("%d", &k);
  for(i=1;i<=k;i++){
    x[i] = y[i] = 0;
    scanf("%d", &a);
    scanf("%d", &size[a]);
    for(j=1;j<=size[a];j++) scanf("%d", &g[a][j]);
  }
  for(i=1;i<=k;i++){
    if(!x[i]) dfs(i);
  }
  for(i=1;i<=k;i++){
    printf("%d %d %d\n", i, x[i], y[i]);
  }
  return 0;
}

Measured memory_bytes: 636
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999

//A_iが一以上であることに気をつける

ll N,K,Q;
ll point[100010];
int main(){
  cin >> N>>K>>Q;

  REP(i,N)point[i]=-Q;
  REP(i,Q){
    ll A;
    scanf("%lld",&A);
    A--;//A１以上なので、調整
    point[A]++;
  }
  REP(i,N){
    if(point[i]>-K){
      printf("Yes\n");
    }
    else printf("No\n");
  }

}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define MAX 100001
#define MOD 1000000007
using namespace std;

ld probability(int n,ld p[] )
{
    int max_tail = n/2 ;

    ld dp[max_tail+1];

    memset(dp , (ld)0 , sizeof(dp));

    dp[0] = (ld)1;

    for(int i=0;i<n;++i)
    {
        
        for(int j=max_tail ;j > 0; --j)
        {
            dp[j] *= p[i];
            dp[j] += dp[j-1]*(1-p[i]);
        }
        dp[0] = dp[0]*p[i];
    }

    ld sum = 0;

    for(int j=0;j<=max_tail;++j)
    {
        sum += dp[j];
    }

    return sum;
}

 
int32_t main()
{
    int n;
    cin>>n;
    ld p[n];
    for(int i=0;i<n;++i)
        cin>>p[i];

    cout << fixed << setprecision(10) << probability(n,p) <<endl;

    return 0;
}

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         StringBuilder sb = new StringBuilder();
         long res = 0L;
         long[] map = new long[N+2];
         for(int x: arr)
            map[x]++;
         for(int i=1; i <= N; i++)
            res += map[i]*(map[i]-1)/2;
         for(int i=0; i < N; i++)
         {
            if(i > 0)
            {
               res -= map[arr[i-1]]*(map[arr[i-1]]-1)/2;
               map[arr[i-1]]++;
               res += map[arr[i-1]]*(map[arr[i-1]]-1)/2;
            }
            res -= map[arr[i]]*(map[arr[i]]-1)/2;
            map[arr[i]]--;
            res += map[arr[i]]*(map[arr[i]]-1)/2;
            sb.append(res+"\n");
         }
         System.out.print(sb);
      }
   }

Measured memory_bytes: 70136
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7
dy = [0,1,0,-1]
dx = [1,0,-1,0]
ddy = [0,1,1,1,0,-1,-1,-1]
ddx = [1,1,0,-1,-1,-1,0,1]

a,b,c = map(int,input().split())
if a <= c <= b or b <= c <= a:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 3064
from collections import deque

s = deque(input())
len_queries = int(input())
queries = [input().split() for _ in range(len_queries)]

is_forward = True
for query in queries:
    if "1" == query[0]:
        is_forward = not is_forward
    else:
        if is_forward:
            if "1" == query[1]:
                s.appendleft(query[2])
            else:
                s.append(query[2])
        else:
            if "1" == query[1]:
                s.append(query[2])
            else:
                s.appendleft(query[2])
if not is_forward:
    s.reverse()
print("".join(s))


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

const ll inf = LLONG_MAX;
ll ans=0;
char maze[200][200];
map<pair<ll,ll>,vector<pair<ll,ll> > > neigh;

void bfs(pair<ll,ll> src)
{
    queue<pair<ll,ll> >q;
    map<pair<ll,ll>,pair<ll,ll> > parent;
    map<pair<ll,ll>,ll> dist;
    q.push(src);
    dist[src]=0;
    parent[src] = src;
    while(!q.empty())
    {
        pair<ll,ll> node = q.front();
        q.pop();
        vector<pair<ll,ll> > tt= neigh[node];
        for(pair<ll,ll> neighbour:tt)
        {
            if(dist.find(neighbour)==dist.end())
            {
                q.push(neighbour);
                dist[neighbour]=dist[node]+1;
                ans = max(ans,dist[neighbour]);
            }
        }
    }
}

int main()
{
    ll r,c;
    cin>>r>>c;
    for(ll i=0;i<200;i++) for(ll j=0;j<200;j++) maze[i][j] = '#';
    for(ll i=0;i<r;i++) for(ll j=0;j<c;j++) cin>>maze[i][j];
    for(ll i=0;i<r;i++)
    {
        for(ll j=0;j<c;j++)
        {
            pair<ll,ll> p = make_pair(i,j);
            vector<pair<ll,ll> > ne;
            if(maze[i][j+1]=='.') ne.push_back(make_pair(i,j+1));
            if(maze[i][j-1]=='.') ne.push_back(make_pair(i,j-1));
            if(maze[i+1][j]=='.') ne.push_back(make_pair(i+1,j));
            if(maze[i-1][j]=='.') ne.push_back(make_pair(i-1,j));
            neigh[p] = ne;
        }
    }
    for(ll i=0;i<r;i++)
    {
        for(ll j=0;j<c;j++)
        {
            if(maze[i][j]!='#')
            bfs(make_pair(i,j));
        }
    }
    cout<<ans<<endl;
}

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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;


int main()
{
    SAM;
    int n,k,sum=0;
    cin>>n>>k;
    int arr[n];
    FOR(i,0,n)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    
    FOR(i,0,k)
    {
        sum+=arr[i];
    }
    cout<<sum;
    
    

    
    
    return 0;
}


Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(){
int A,B,C,D;
scanf("%d%d%d%d",&A,&B,&C,&D);
if(A*B>=C*D){
printf("%d",A*B);
}
else{
printf("%d",C*D);
}




}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n, q;
vector<int> al;

bool solve(int m, int s) {
  if (m == n-1) {
    return al.at(m) == s || s == 0;
  }
  return (solve(m+1, s) || solve(m+1, s-al.at(m)));
}

int main() {
  // 分割統治法：2つ以上の小さな問題に分割して再帰で部分問題の解を求めて
  //           結果を統合することで解を求める
  cin >> n;
  for (int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    al.push_back(tmp);
  }
  cin >> q;
  for (int i=0; i<q; i++) {
    int tmp;
    cin >> tmp;
    if (solve(0, tmp)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}




Measured memory_bytes: 3156
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long H, W;
  cin >> H >> W;
  long foo = 0;
  rep (i, H) {
    string A;
    cin >> A;
    rep (j, W) if (A[j] == '#') foo++;
  }
  if (foo == H + W - 1) puts("Possible");
  else puts("Impossible");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long dis = Math.abs(n - m);
		long mod = 1000000007;
		if(dis >= 2) {
			System.out.println(0);
		} else if(dis == 1) {
			long a = 1;
			long b = 1;
			for(long i = n ; i >= 1 ; i--) a = a * i % mod;
			for(long i = m ; i >= 1 ; i--) b = b * i % mod;
			System.out.println(a * b % mod);
		} else if(dis == 0) {
			long a = 1;
			long b = 1;
			for(long i = n ; i >= 1 ; i--) a = a * i % mod;
			for(long i = m ; i >= 1 ; i--) b = b * i % mod;
			System.out.println(a * b * 2 % mod);
		}
	}
}


Measured memory_bytes: 23252
import math


def get_input():
    a, b, x = map(int, input().split())
    return a, b, x


def calc_tan_theta(a, b, x):
    mass = a * a * b
    if x >= mass / 2:
        return 2 * (b - x / (a * a)) / a
    else:
        return 0.5 * a * b * b / x


def main():
    a, b, x = get_input()
    tan_theta = calc_tan_theta(a, b, x)
    degree = math.degrees(math.atan(tan_theta))
    print(degree)


main()


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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, u, v, m;
	cin >> n >> u >> v >> m;
	unordered_map<int, pair<int, int>> a, b;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int val;
			cin >> val;
			a[val] = make_pair(i, j);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int val;
			cin >> val;
			b[val] = make_pair(i, j);
		}
	}
	vector<int> r1(n), r2(n), c1(n), c2(n);
	int na1 = 0, na2 = 0, ne1 = 0, ne2 = 0;
	int cnt1 = 0, cnt2 = 0;
	int res = 0;
	bool end = false;
	for (int i = 0; i < m; i++) {
		int val;
		cin >> val;
		if (!res && a.count(val)) {
			int x, y;
			tie(x, y) = a[val];
			++r1[x];
			if (r1[x] == n) ++cnt1;
			++c1[y];
			if (n > 1 && c1[y] == n) ++cnt1;
			if (n > 1 && x == y) {
				++na1;
				if (na1 == n) ++cnt1;
			}
			if (n > 1 && x + y == n - 1) {
				++ne1;
				if (ne1 == n) ++cnt1;
			}
		}
		if (!res && b.count(val)) {
			int x, y;
			tie(x, y) = b[val];
			++r2[x];
			if (r2[x] == n) ++cnt2;
			++c2[y];
			if (n > 1 && c2[y] == n) ++cnt2;
			if (n > 1 && x == y) {
				++na2;
				if (na2 == n) ++cnt2;
			}
			if (n > 1 && x + y == n - 1) {
				++ne2;
				if (ne2 == n) ++cnt2;
			}
		}
		if (end) continue;
		if (cnt1 >= u && cnt2 >= v) {
			end = true;
		}
		else if (cnt1 >= u) {
			res = 1;
			end = true;
		}
		else if (cnt2 >= v) {
			res = -1;
			end = true;
		}
	}
	puts(res == 0 ? "DRAW" : res > 0 ? "USAGI" : "NEKO");
	return 0;
}



Measured memory_bytes: 16280
N,K =map(int,input().split())

child = [0]*N

for i in range(1,K+1):
    d = int(input())
    A = map(int,input().split())
    for j in A:
        child[j-1] += 1

ans = 0
for i in child:
    if i == 0:
        ans += 1

print(ans)

        

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

using namespace std;
using ll = long long;

const int INF = (int)1e9;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

ll cost(ll state, ll target){
        if(state==0||state==4) return target;
        else if(state==2) return (target&1)?0:1;
        else return (target)?target%2:2;
}

int main() {
    int L; cin>>L;
    vector<ll> A(L+1);
    for (int i = 0; i < L; i++) cin>>A[i]; A[L]=0;
    vector<vector<ll>>dp(L+2, vector<ll>(5, INF));
    fill(dp[0].begin(), dp[0].end(), 0);
    
    for(int i = 1; i <= L+1; i++)
    {
        for(int j = 0; j < 5; j++)
        {
            ll mi = *min_element(dp[i-1].begin(), dp[i-1].begin() + j + 1);
            //各状態はその前の状態か同じ状態からしか遷移できないため
            dp[i][j] = mi + cost(j, A[i-1]);
        }
    }

    cout<<dp[L+1][4]<<endl;

    return 0;
}

Measured memory_bytes: 15872