akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using vi = vector<int>;
template <class T>
using Grid = vector<vector<T>>;

int H, W;
Grid<char> grid;
Grid<int> h,v;

int hor(Grid<char> &grid, int i, int j, int count) {
    if (j >= W)
        return count;
    if (grid[i][j] == '#') {
        h[i][j] = 0;
        return count;
    }
    return h[i][j] = hor(grid, i, j + 1, count + 1);
}
int ver(Grid<char> &grid, int i, int j, int count) {
    if (i >= H)
        return count;
    if (grid[i][j] == '#') {
        v[i][j] = 0;
        return count;
    }
    return v[i][j] = ver(grid, i + 1, j, count + 1);
}

int main() {
    cin >> H >> W;
    grid = Grid<char>(H, vector<char>(W));
    rep(i, H) rep(j, W) cin >> grid[i][j];
    h = Grid<int>(H, vector<int>(W, -1));
    v = Grid<int>(H, vector<int>(W, -1));

    rep(i, H) rep(j, W) {
        if (h[i][j] == -1)
            hor(grid, i, j, 0);
        if (v[i][j] == -1)
            ver(grid, i, j, 0);
    }
    int ans = 0;
    rep(i, H) rep(j, W) {
        ans = max(ans, h[i][j] + v[i][j]);
    }
    cout << ans - 1 << endl;
}

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

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

  int min=numeric_limits<int>::max();
  int ans=0;
  for (int i = 1; i <= n; i++) {
    int p;
    cin >> p;
    if(p<=min){
      ans++;
      min = p;
    }
  }

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


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int x; cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;

}








Measured memory_bytes: 3648
#include <iostream>
#include <vector>

int main(){
  int N, K;
  int a,d=0;
  
  std::cin >> N >> K;

  std::vector<int> A;

  for(int i=0; i<K; i++){
    std::cin >> d;
    for(int j=0; j<d; j++){
      std::cin >> a;
      A.push_back(a);
    }
  }

  std::sort(A.begin(), A.end());
  A.erase(std::unique(A.begin(), A.end()), A.end());

  std::size_t size = A.size();
  std::cout << N-size << std::endl;
}


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

#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
#define pb push_back
#define int long long
#define ll long long
#define lson node << 1
#define rson (node << 1) + 1
#define endl "\n"

const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const double pi = acos(-1);

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int qpow(int a, int n)
{
    int b = 1;
    while (n)
    {
        if (n & 1)
            b = a * b % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return b;
}

class Prime_Number
{
public:
    int prime[maxn], s, v[maxn];
    void prime_init(int n)
    {
        for (int i = 2; i <= n; i++)
        {
            if (!v[i])
            {
                prime[s++] = i;
                for (int j = 1; j * i <= n; j++)
                    v[i * j] = 1;
            }
        }
    }
};

//**************************
int a[maxn];
void solve()
{
    ll n;
    cin>>n;
    int ans=1,ok=1;
    ll k=7;
    while(k%n)
    {
        k=k*10+7;
        k%=n;
        ans++;
        a[k]++;
        if(a[k]==2)
            {
                ok=0;
                break;
            }
    }
    if(ok)
    cout<<ans;
    else 
        cout<<-1;
}
signed main()
{
    // int t;
    // cin >> t;
    // while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 11448
N,M = map(int,input().split())
rows = [list(map(int,input().split())) for _ in range(M)]

set_land1 = set()
set_landN = set()
for i in range(M):
    if rows[i][0]==1 or rows[i][1]==1:
        set_land1.add(rows[i][0])
        set_land1.add(rows[i][1])
    elif rows[i][0]==N or rows[i][1]==N:
        set_landN.add(rows[i][0])
        set_landN.add(rows[i][1])

set_root = set_land1 - set_landN
ans = "POSSIBLE"
if len(set_land1) == len(set_root):
    ans = "IMPOSSIBLE"

print(ans)


Measured memory_bytes: 63624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

    int sn = s.size();
    int tn = t.size();
    vector<vector<int>> dp(sn + 1, vector<int>(tn + 1));
    dp[0][0] = 0;

    rep(i, sn){
        rep(j, tn){
            if(s[i] == t[j]){
                chmax(dp[i+1][j+1], dp[i][j] + 1);
            }
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    string ans = "";
    int i=sn, j=tn;
    while(i > 0 && j > 0){
        int now = dp[i][j];
        int shaveS = dp[i-1][j];
        int shaveT = dp[i][j-1];
        if(now == shaveS){
            --i;
        }else if(now == shaveT){
            --j;
        }
        else
        {
            ans = s[i-1] + ans;
            --i; --j;
        }
    }

    cout <<  ans <<  endl;

    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(1<<30)-1;
const ll INFl=9223372036854775807;
const int MAX=10000;
const ll MOD=1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
char s[200100];

int main(){
	cin>>n;
	int b=0;
	int w=0;
	REP(i,n){
		cin>>s[i];
		if(s[i]=='.')w++;
		else b++;
	}
	int sb[n];
	int sw[n];
	if(s[0]=='.'){
		sb[0]=0;
		sw[0]=w;
	}else{
		sb[0]=0;
		sw[0]=w;
	}
	for(int i=1;i<n;i++){
		if(s[i-1]=='#'){
			sb[i]=sb[i-1]+1;
		}else{
			sb[i]=sb[i-1];
		}
		if(s[i-1]=='.'){
			sw[i]=sw[i-1]-1;
		}else{
			sw[i]=sw[i-1];
		}
	}
	int ans=min(b,w);
	REP(i,n)
		ans=min(ans,sw[i]+sb[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2048
N = int(input())
S = [input() for i in range(N)]
AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
    if i == "AC":
        AC += 1
    elif i == "WA":
        WA += 1
    elif i == "TLE":
        TLE += 1
    else:
        RE += 1

a = "AC x " + str(AC)
b = "WA x " + str(WA)
c = "TLE x " + str(TLE)
d = "RE x " + str(RE)

print(a)
print(b)
print(c)
print(d)

Measured memory_bytes: 16324
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll H; cin >> H;
    ll cnt = 0;
    ll k = 1;
    while (H > 0) {
        cnt += k;
        H /= 2LL;
        k *= 2LL;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    mt = 0
    t = 0
    for i in range(n):
        a = int(readline())
        if a == 0:
            mt += t // 2
            t = 0
        else:
            t += a
    print(mt + t // 2)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 40684
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	W, H , x, y = map(int, input().split(" "))
	ans1 = W * H /2
	ans2 = 0
	if x == W/2 and y == H/2:
		ans2 = 1
	
	print("{} {}".format(ans1, ans2))
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 13184
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    K,S=map(int,input().split())

    

    cnt=0
    for i in range(K+1):
        for j in range(K+1):
            if i+j<=S and 0<=S-i-j<=K:
                cnt+=1

    print(cnt)
resolve()

Measured memory_bytes: 40556
from collections import Counter

n=int(input())
v=list(map(int,input().split()))

v_odd=v[::2]
v_even=v[1::2]
c_odd=Counter(v_odd)
cm_odd=c_odd.most_common()
c_even=Counter(v_even)
cm_even=c_even.most_common()

if cm_odd[0][0]!=cm_even[0][0]:
    ans=(len(v_odd)-cm_odd[0][1]+len(v_even)-cm_even[0][1])
elif len(cm_odd)==1 and len(cm_even)==1:
    ans=n//2
elif len(cm_odd)==1:
    ans=len(v_even)-cm_even[1][1]
elif len(cm_even)==1:
    ans=len(v_odd)-cm_odd[1][1]
else:
    ans=min((len(v_odd)-cm_odd[1][1])+(len(v_even)-cm_even[0][1]),(len(v_odd)-cm_odd[0][1])+(len(v_even)-cm_even[1][1]))
print(ans)


Measured memory_bytes: 21952
import java.awt.geom.*;
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        new Main(); 
    }
 
    public Main() {
    	new aoj0058().doIt();
    }
    class aoj0058{
    	void doIt(){
    		while(sc.hasNext()){
                double x1=sc.nextDouble();
                double y1=sc.nextDouble();
                double x2=sc.nextDouble();
                double y2=sc.nextDouble();
                double x3=sc.nextDouble();
                double y3=sc.nextDouble();
                double x4=sc.nextDouble();
                double y4=sc.nextDouble();  
                if(Math.abs((x2-x1)*(x4-x3)+(y2-y1)*(y4-y3))<1e-10)System.out.println("YES");
                else System.out.println("NO");
            }
    	}
    }
}

Measured memory_bytes: 29560
/**
 *      purpose : ABC 133 A
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, a, b; cin >> n >> a >> b;
  cout << min(n * a, b) << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
const int Mod = 1e9 + 7;
int n, f[110][110][110], Ans, a[110];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n + n - 1; ++i) scanf("%d", &a[i]);
	std::sort(a + 1, a + n + n);
	f[0][0][0] = 1;
	//n = n / 2;
	--n;
	for(int i = 0; i < n; ++i)
		for(int j = 0; j <= i << 1; ++j)
			for(int k = 0; k <= i << 1; ++k) if(f[i][j][k])
			{
				int t = f[i][j][k], A = a[n + 1 - i] != a[n - i], B = a[n + 1 + i] != a[n + 2 + i];
			//	printf("%d %d %d\n", i, j, k);
				(f[i + 1][j + A][k + B] += t) %= Mod; //straight
			//	if(k + 2 <= i + 1) 
				for(int u = 0; u < j + A; ++u) //left
					(f[i + 1][u][k + 1 + B] += t) %= Mod;
			//	if(j + 2 <= i + 1) 
				for(int u = 0; u < k + B; ++u) //right
					(f[i + 1][j + 1 + A][u] += t) %= Mod;
			}
	//puts("#");
	/*for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= n + n; ++j)
			for(int k = 0; k <= n + n; ++k) if(f[i][j][k])
				printf("[%d %d %d = %d]\n", i, j, k, f[i][j][k]);*/
	for(int i = 0; i <= n + n + 1; ++i) 
		for(int j = 0; j <= n + n + 1; ++j)
			(Ans += f[n][i][j]) %= Mod;
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, len;
string s;

int solve(int l, int r) {
    l++;
    // printf("l = %lld, r = %lld, ", l, r);
    // cout << s.substr(l, r-l) << endl;
    int cnt = 0;
    if(s[l] == '[') {
        vector<int> ns;
        int nl = -1, nr = -1;
        rep(i,l,r) {
            if(s[i] == '[') {
                cnt++;
                if(cnt == 1) nl = i;
            }
            else if(s[i] == ']') {
                cnt--;
                if(cnt == 0) {
                    nr = i;
                    int val = solve(nl, nr);
                    ns.push_back(val);
                }
            }
        }
        sort(ns.begin(), ns.end());
        int ret = 0, sz = ((int)ns.size() - 1) / 2 + 1;
        rep(i,0,sz) ret += ns[i];
        return ret;
    }
    else {
        int ret = 0;
        rep(i,l,r) ret = ret * 10 + (s[i] - '0');
        return (ret - 1) / 2 + 1;
    }
}

signed main() {
    cin >> N;
    while(N--) {
        cin >> s;
        len = s.length();
        cout << solve(0, len-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3152
#include<stdio.h>
#include<stdlib.h>
            
int pop(void);
void push(int);
int stack[100],i=0;
            
int pop(void)
{
    return stack[--i];
}
            
void push(int num)
{
    stack[i++] = num;
}
int main()
{
    char c[100];
    int x,y;
    while( scanf("%s",c) != EOF )
    {
        if( c[0] == '+')
        {
            x = pop();
            y = pop();
            push(x+y);
        }
        else if( c[0] == '-' )
        {
            x = pop();
            y = pop();
            push(y-x);
        }
        else if( c[0] == '*' )
        {
            x = pop();
            y = pop();
            push(x*y);
        }
        else
        {
            push(atoi(c));
        }
    }
        printf("%d\n",stack[0]);
        return 0;
}


Measured memory_bytes: 2068
#include <iostream>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string.h>

using namespace std;


char S[200];
char T[200];
int L;

int main(int argc, char** argv) {
    cin >> S >> T;
    L = strlen(S);
    for (int i=0; i<L; i++) {
        bool ok = true;
        for (int j=0; j<L; j++) {
            if (S[(i + j) % L] != T[j]) ok = false;
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)
#define MAX ((ull)(1e9)+1)

int main(){
	int n;
	cin >> n;
	int h[n], m[n], ans=0;
	for(int i=0; i<n; i++) cin >> h[i];
	m[0]=h[0];
	for(int i=1; i<n; i++) m[i]=max(m[i-1], h[i]);
	for(int i=0; i<n; i++){
		if(m[i]<=h[i]) ans++;
	}
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    X = []
    for i in range(N):
        a = int(input())
        X.append([])
        for j in range(a):
            x, y = [int(x) for x in input().split()]
            X[i].append([x, y])

    ans = 0
    for i in range(2 ** N):
        tmp = 0
        is_mujun = False
        for j in range(N):
            if i >> j & 1:
                tmp += 1
                for k in X[j]:
                    if (i >> (k[0] - 1) & 1) != k[1]:
                        is_mujun = True
                        break
        if not is_mujun:
            ans = max(ans, tmp)

    print(ans)







if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
object Main extends App {
    import scala.io.StdIn._
    val n = readLine().toInt
    var w_ar: Array[String] = Array.empty
    for (_ <- 1 to n){
      w_ar = w_ar :+ readLine()
    }

    def hoge(ar: Array[String], nn: Int):String = {
      for (i<-0 to nn-2){
        if (ar(i).last != ar(i+1).head) {
          return "No"
        }
      }
      "Yes"
    }

    if (w_ar.length != w_ar.distinct.length) {
      println("No")
    } else {
      println(hoge(w_ar, n))
    }
}

Measured memory_bytes: 27088
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> ant(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> ant[i];
    }
    int k;
    cin >> k;
    sort(ant.begin(),ant.end());
    if(ant[4]-ant[0] > k)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std;
int main(void){
    while(1){
        int n;
        cin>>n;
        if(n==0)break;
        int data[n+1][101],cnt[n];
        for(int s=1;s<=n;s++){
            int k;
            cin>>k;
            for(int i=0;i<k;i++)cin>>data[s][i];
            cnt[s]=k;
        }
        int tsu;
        cin>>tsu;
        int target[tsu];
        for(int i=0;i<tsu;i++)cin>>target[i];
        //until input
        
        //under seach
        int cnts=0,memo;
        for(int s=1;s<=n;s++){
            int z=0;
            for(int i=0;i<cnt[s];i++){
                for(int t=0;t<tsu;t++){
                    if(data[s][i]==target[t])z++;
                }
            }
            if(z==tsu){
                cnts++;
                memo=s;
            }
        }
        if(cnts==0)cout<<"-1\n";
        else if(cnts>1)cout<<"-1\n";
        else if(cnts==1)cout<<memo<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 1200
N, D = map(int, input().split())

r = N 
i = 0

"""
for k in range(50):
    r = r - (2 * D + 1)
    print("r = ", r)
    if r < (2 * D + 1):

        break
"""
a = N // (2*D+1)

if (N%(2*D+1))==0:
    print(a)
else:
    print(a+1)

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



int main(){
  int k,n;
  cin >> k >> n;
  vector<int>  a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  int max_dist = 0;
  
  rep(i,n-1){
    max_dist = max(max_dist,a.at(i+1)-a.at(i));
  }
  
  max_dist = max(max_dist, k+a.at(0)-a.at(n-1));
  
  int ans = k - max_dist;
  cout << ans << endl;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =99999999999;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




//10億7。　　　100000007
//2*2行列 H*W
//vector<vector<int>> vec(H,vector<int>(W));
//for(int i=0;i<H;i++){
//for(int j=0;j<W;j++){
//cin>>vec[i][j];
//  }
//}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit(a)
//pair宣言　pair<int,int> p(5,7);
//ソート　sort(vec.begin(),vec.end());



int main(){
cout<<fixed<<setprecision(10);
 
int N;cin>>N;
  if(N%2==0){cout<<(N/2)*(N/2)<<endl;}else{
    cout<<((N/2)+1)*(N/2)<<endl;}
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  string A, B;
  cin >> A >> B;

  if(A.size() > B.size()){
    cout << "GREATER" << endl;
    return 0;
  } else if (A.size() < B.size()){
    cout << "LESS" << endl;
    return 0;
  }

  for (int i = 0; i < A.size(); i++) {
    if(A[i] > B[i]){
      cout << "GREATER" << endl;
      return 0;
    } else if (A[i] < B[i]){
      cout << "LESS" << endl;
      return 0;
    }
  }

  cout << "EQUAL" << endl;
  return 0;

}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3000+5;
int dp[maxn][maxn];
int pre[maxn][maxn];
int sL, tL;
string s, t;


void LCS() {
	memset(dp, 0, sizeof(dp));

	for(int i= 0; i<sL; i++){
		for(int j=0; j<tL; j++){
			if(s[i] == t[j]){
				dp[i+1][j+1] = dp[i][j] + 1;
				pre[i+1][j+1] = 3;
			}
			else{
				if(dp[i][j+1] > dp[i+1][j]){
					dp[i+1][j+1] = dp[i][j+1];
					pre[i+1][j+1] = 1;//上
				}
				else{
					dp[i+1][j+1] = dp[i+1][j];
					pre[i+1][j+1] = 2;
				}
			}
		}
	}
}

void print_LCS(int x, int y) {
	if(x==0 || y==0) return;
	if(pre[x][y] == 3){
		print_LCS(x-1, y-1);
		cout << s[x-1];
	}
	else if(pre[x][y] == 1){
		print_LCS(x-1, y);
	}
	else if(pre[x][y] == 2){
		print_LCS(x, y-1);
	}
}





int main(int argc, char const *argv[])
{
	while(getline(cin, s)) {
		getline(cin, t);
		memset(pre, 0, sizeof(pre));
		sL = s.length();
		tL = t.length();
		LCS();
		print_LCS(sL, tL);
		cout << endl;
	} 
	return 0;
}

Measured memory_bytes: 74316
#include<iostream>
using namespace std;
const int inf=1e9+7;
#define ll long long
int main(){
	int i,n,s=1;
	cin>>n;
	for(i=1;i<=n;i++)
	   {
	   	   s=(ll)s*i%inf;
	   }
	cout<<s;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define all(v) v.begin(),v.end()

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }

class Solver {
  public:
    bool solve() {
        ll H, W, N; cin >> H >> W >> N;
        map<pii, int> rect;
        rep(i, N) {
            int x, y; cin >> y >> x;
            x--; y--;
            for(int dy = -2; dy <= 0; dy++) {
                for(int dx = -2; dx <= 0; dx++) {
                    int lx = x + dx;
                    int ly = y + dy;
                    int rx = lx + 2;
                    int ry = ly + 2;
                    if(0 <= lx and lx < W and 0 <= ly and ly < H) {
                        if(0 <= rx and rx < W and 0 <= ry and ry < H) {
                            rect[make_pair(ly, lx)] += 1;
                        }
                    }
                }
            }            
        }
        vector<ll> ans(10);
        ll zero = (H - 2) * (W - 2);
        for(auto p : rect) {
            ans[p.second] += 1;
            zero -= 1;
        }
        ans[0] = zero;
        for(auto a : ans) cout << a << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

int main() {
  int n,l;
  cin >> n >> l;
  vector<string>mdata(n);
  vector<int>ds(n);
  for(int i = 0;i < n;i++){
    cin >> mdata.at(i);
  }
  for(int i = 0;i < n;i++){
    int c = 0;
    for(int j = 0;j < n;j++){
      if(j != i){
        if(mdata.at(i) > mdata.at(j)){
          c++;
        }
        else if(mdata.at(i) == mdata.at(j) && i > j){
          c++;
        }
      }
    }
    ds.at(i) = c;
  }
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      if(i == ds.at(j)){
        if(i != n-1){
          cout << mdata.at(j);
        }
        else{
          cout << mdata.at(j) << endl;
        }
      }
    }
  }
}


Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2017/10/08 20:08:42 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

int main()
{
    IOS;
    map<int, int> mp;
    int n;
    cin>>n;
    for (int j = 1; j <= n; ++ j)
    {
        int x;
        cin>>x;
        mp[x] ++;
    }
    bool flag = 1;
    int m;
    cin>>m;
    for (int j = 1; j <= m; ++ j)
    {
        int x;
        cin>>x;
        mp[x] --;
        if (0 > mp[x]) flag = 0;
    }
    if (flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define mi(x,y) (x<y?x:y)
#define N 100010

int main() {
	//メモリーのテスト
	int*mem=(int*)calloc(3<<26,sizeof(int));
	for(int q=0;q<3<<26;q++)mem[q]=q;
  
	int n, h[N] = { 0 }, dp[N] = { 0 };
	scanf("%d", &n);
	rep(i, n)scanf("%d", &h[i+1]);
	dp[0] = N;
	Rep(i,2,n+1)dp[i]=mi(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	printf("%d", dp[n]);
}

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

using namespace std;

int main(){
    string s;
    //s = "abcdabc";
    cin >> s;
    int m = 0;
    int n = s.size();

    for (int i = 0; i < n / 2; ++i){
        if(s[i] != s[(n-1)-i]){
            m++;
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n % 2 == 0) {
            System.out.println(n);
        } else {
            System.out.println(n * 2);
        }
    }    
}


Measured memory_bytes: 21844
def main():
    from itertools import permutations, tee

    INF = 1 << 30

    N, M, R = map(int, input().split())
    *r, = (int(x) - 1 for x in input().split())

    d = [[INF] * N for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        d[a][b] = d[b][a] = c

    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(
                    d[i][j],
                    d[i][k] + d[k][j]
                )

    ans = INF
    for perm in permutations(r):
        perm_iter = iter(perm)
        frm_iter, to_iter = tee(perm_iter, 2)
        next(to_iter)
        t = 0
        for frm, to in zip(frm_iter, to_iter):
            t += d[frm][to]
        ans = min(ans, t)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 48104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
  	Cout((n+110)/111*111);
}



Measured memory_bytes: 256
n,a,b = map(int,input().split())
mod = 10**9 + 7
ans = pow(2,n,mod) - 1
fa = 1
fb = 1
for i in range(1, a+1):
    fa *= i
    fa %= mod
for i in range(1, b+1):
    fb *= i
    fb %= mod

fa = pow(fa, mod-2, mod)
fb = pow(fb, mod-2, mod)

for i in range(a):
    fa *= n - i
    fa %= mod
for i in range(b):
    fb *= n - i
    fb %= mod

print((ans - fa - fb) % mod)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main() {
  int n,m;
  cin>>n>>m;
  int a[10000];
  for (int i=0; i<1<<n; i++) {
    a[i]=1e9;
  }
  a[0]=0;
  for (int i=0; i<m; i++) {
    int v,b;
    cin>>v>>b;
    int open=0;
    for (int j=0; j<b; j++) {
      int c;
      cin>>c; c--;
      open|=1<<c;
    }
    for (int j=0; j<1<<n; j++) {
      a[j|open]=min(a[j|open],a[j]+v);
    }
  }
  if (a[(1<<n)-1]>1e7) cout<<-1<<endl;
  else cout<<a[(1<<n)-1]<<endl;   
  return 0;
}





Measured memory_bytes: 384
import math
import sys
from collections import deque
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
ans=0
while a<=b:
  a*=2
  ans+=1
print(ans)

Measured memory_bytes: 3444
function Main(input) {
  input = input.split("\n");
  var K = parseInt(input[0]);
  var S = input[1];
  if(S.length<=K){
    var ans = S;
  }else{
    var ans = S.substr(0,K)+"...";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n == 1) {
			System.out.println("Hello World");
		} else {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a + b);
		}
	}

}

Measured memory_bytes: 21844
void main(){
	int a, b, c, d;
	readf("%d %d %d %d\n", &a, &b, &c, &d);
	double[2] live;
	live[0] = (a%d==0)? a/d: a/d+1;
	live[1] = (c%b==0)? c/b: c/b+1;
	if(live[0] >= live[1])writeln("Yes");
	else writeln("No");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2768
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = InputNum();
            var a = new List<int>();
            for (int i = 0; i < n; i++)
            {
                a.Add(InputNum());
            }
            int ans = 0;
            int next = 0;
            while (ans <= 100010)
            {
                next = a[next] - 1;
                ans++;
                if (next == 1) break;
            }
            if (ans >= 100001) ans = -1;
            WriteLine(ans);
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 14048
// D.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 5050;

int n, mod, dp[MAX_N];

int main()
{
    scanf("%d%d", &n, &mod), dp[0] = 1;
    for (int i = 1; i < n; i++)
        for (int j = min(n - i + 1, i), k = j; j < n; j++)
            dp[j] = (0LL + dp[j] + dp[j - k]) % mod;
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = (0LL + ans + 1LL * dp[i] * (n - i) % mod) % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3808
N = int(input())
lremain = []
rremain = []

for i in range(N):
	S = input()
	left = 0
	right = 0
	for c in S:
		if c == "(":
			left += 1
		else:
			if left == 0:
				right += 1
			else:
				left -= 1
	if left == 0 and right == 0:
		continue
	lremain.append(left)
	rremain.append(right)

N = len(lremain)

if sum(lremain) != sum(rremain):
	print("No")
	exit()

head = 0
tail = 0
removei = set()
for i in range(N):
	if rremain[i] == 0:
		head += lremain[i]
		removei.add(i)
	if lremain[i] == 0:
		tail += rremain[i]
		removei.add(i)

lnr = []
for i in range(N):
	if not i in removei:
		lnr.append((lremain[i], rremain[i]))

N = len(lnr)
lnr.sort(key = lambda x: (x[1]-x[0]))

for i in range(N):
	if head < lnr[i][1]:
		print("No")
		exit()
	head -= lnr[i][1]
	head += lnr[i][0]

if head == tail:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 223700
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//キーボード入力メソッド
		Scanner sc = new Scanner(System.in);

		double r = sc.nextDouble();
		double Pi = Math.PI;
		double menseki_x = r * r * Pi;
		double syuu_y = 2 * r * Pi;

		//fの小数点以下の桁数を指定(5桁)
				BigDecimal menseki = new BigDecimal(menseki_x);
				menseki = menseki.setScale(5, BigDecimal.ROUND_HALF_UP);
				BigDecimal syuu = new BigDecimal(syuu_y);
				syuu = syuu.setScale(5, BigDecimal.ROUND_HALF_UP);

		//出力
		System.out.println(menseki +" "+ syuu);

	}

}



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

int main(void)
{
    int i, j;
    vector<int> a(6);
    vector<int> c(4);
    int count2 = 0;

    for(i = 0; i < 4; i++) c.at(i) = 0;

    for (i = 0; i < 6; i++) {
        cin >> a.at(i);
        for (j = 1; j < 5; j++) {
            if (a.at(i) == j){
                c.at(j - 1) += 1;
                break;
            }
        }
    }

    for (i = 0; i < 4; i++) {
        if (c.at(i) == 2) count2++;
    }
    
    if (count2 == 2){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 140
//C - Maximal Value
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n;

    cin >> n;

    vector<int> b(n-1);
    REP(i, n-1) cin >> b[i];

    int ans = b[0];
    FOR(i, 0, n-3){
        ans+=min(b[i],b[i+1]);
    }
    ans+=b[n-2];

    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused)]
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let n: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s.parse().unwrap()
    };

    let mut testimonies: Vec<Vec<(usize, bool)>> = vec![vec![]; n];

    for i in 0..n {
        let a_i: usize = {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_right().to_owned();
            s.parse().unwrap()
        };

        for j in 0..a_i {
            let (x, y): (usize, usize) = {
                let mut s = String::new();
                std::io::stdin().read_line(&mut s).unwrap();
                let s = s.trim_right().to_owned();
                let mut ws = s.split_whitespace();
                let a = ws.next().unwrap().parse().unwrap();
                let b = ws.next().unwrap().parse().unwrap();
                (a, b)
            };

            let honest = y == 1;
            // 0-originに
            testimonies[i].push((x - 1, honest));
        }
    }

    let mut max = 0;
    'outer: for bits in 0..(1 << n) {
        let mut honest_count = 0;
        for i in 0..n {
            if is_honest(bits, i) {
                honest_count += 1;
                for &(x, y) in &testimonies[i] {
                    if is_honest(bits, x) != y {
                        // debugln!("{:0>8b}: ng, x = {}", bits, x);
                        continue 'outer;
                    }
                    // debugln!("{:0>8b}: ok", bits);
                }
            }
        }
        if max < honest_count {
            max = honest_count;
        }
    }

    println!("{}", max);
}

fn is_honest(bits: usize, i: usize) -> bool {
    bits & (1 << i) > 0
}


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

int N;
vector<vector<char> > G;
vector<bool> chk;

int main() {
    scanf("%d", &N);
    G = vector<vector<char> >(N, vector<char>(N));
    chk = vector<bool>(N, false);
    bool poss = false;
    for(int i = 0; i < N; i++) {
        scanf("\n");
        for(int j = 0; j < N; j++) {
            scanf("%c", &G[i][j]);
            if(G[i][j] == '#') {
                chk[j] = true;
                poss = true;
            }
        }
    }
    if(!poss) {
        printf("-1");
        return 0;
    }
    int mn = 1e9;
    for(int i = 0; i < N; i++) {
        if(chk[i]) {
            int cnt = 0;
            for(int j = 0; j < N; j++) {
                if(G[i][j] == '.') cnt++;
            }
            mn = min(mn, cnt);
        }
        else {
            int cnt = 1;
            for(int j = 0; j < N; j++) {
                if(G[i][j] == '.') cnt++;
            }
            mn = min(mn, cnt);
        }
    }
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(G[j][i] == '.') {
                cnt++;
                break;
            }
        }
    }
    printf("%d", mn + cnt);
}


Measured memory_bytes: 640
A=list(list(map(int,input().split())) for _ in range(3))
N=int(input())
B=list(int(input()) for _ in range(N))

R=[[0,0,0],[0,0,0],[0,0,0]]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if B[i]==A[j][k]:
                R[j][k]=1

ans=0

for l in range(3):
    if R[l][0]==1 and R[l][1]==1 and R[l][2]==1:
        ans=1

for m in range(3):
    if R[0][m]==1 and R[1][m]==1 and R[2][m]==1:
        ans=1

if R[0][0]==1 and R[1][1]==1 and R[2][2]==1:
    ans=1

if R[0][2]==1 and R[1][1]==1 and R[2][0]==1:
    ans=1

#print(R)

if ans==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n = int(input())
h = tuple(map(int, input().split()))

c = [0] * n
c[0] = 0
c[1] = abs(h[0] - h[1])

for i in range(2, n):
    c[i] = min(c[i - 1] + abs(h[i - 1] - h[i]), c[i - 2] + abs(h[i - 2] - h[i]))

print(c[-1])


Measured memory_bytes: 14184
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,L,R) for(i=L;i<R;i++)
#define REP(i,N) FOR(i,0,N)
int main(){
  ll N,M,Q,i,j,ans=0;cin>>N>>M>>Q;ll X[4][Q],A[N];REP(i,N)A[i]=1;
  REP(i,Q)REP(j,4)cin>>X[j][i];
  while(1){
    ll p=0;
    REP(i,Q)if(A[X[1][i]-1]-A[X[0][i]-1]==X[2][i])p+=X[3][i];
    ans=max(ans,p);
    if(A[0]==M)break;i=N-1;while(A[i]==M)i--;A[i]++;FOR(j,i+1,N)A[j]=A[i];
  }
  cout<<ans<<endl;
  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A, A + N);
    long long ans = 0;
    if (N % 2 == 0)
    {
        for (int i = N / 2; i < N; i++)
        {
            ans += 2 * A[i];
        }
        ans -= A[N - 1];
    }
    else
    {
        for (int i = N / 2; i < N; i++)
        {
            ans += 2 * A[i];
        }
        ans = ans - A[N/2] - A[N-1];
    }
    cout << ans << endl;
}

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

int main(){

    int n;
    cin >> n;

    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }

    set<int> s(a.begin(), a.end());
    bool unique = false;

    if(a.size()==s.size())
        unique = true;

    if(unique == true)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 10368
from heapq import *
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.parents=[-1]*n
  def find(self,x):
    if self.parents[x]<0:
      return x
    else:
      self.parents[x]=self.find(self.parents[x])
      return self.parents[x]
  def unite(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x==y:
      return
    if self.parents[x]>self.parents[y]:
      x,y=y,x
    self.parents[x]+=self.parents[y]
    self.parents[y]=x
  def size(self,x):
    return -size.parents[self.find(x)]
  def same(self,x,y):
    return self.find(x)==self.find(y)
  def members(self,x):
    root=self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]
  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]
  def group_count(self):
    return len(self.roots())
n=int(input())
X=[]
Y=[]
edge=[] 
for i in range(n):
  x,y=map(int,input().split())
  X.append((x,i))
  Y.append((y,i))
  edge.append((x,y))
X.sort()
Y.sort()
hq=[]
heapify(hq)
for i in range(n-1):
  x1,j1=X[i]
  x2,j2=X[i+1]
  y1,k1=Y[i]
  y2,k2=Y[i+1]
  heappush(hq,(x2-x1,j1,j2))
  heappush(hq,(y2-y1,k1,k2))
uf=UnionFind(n)
ans=0
while hq:
  w,s,t=heappop(hq)
  if uf.find(s)!=uf.find(t):
    uf.unite(s,t)
    ans+=w
print(ans)

Measured memory_bytes: 57956
N = int(input())
a = list(map(int, input().split()))
rate = [400 * i for i in range(9)]
nums = [0] * 8
tourist = 0

for i in range(N):
    for j in range(8):
        if rate[j] <= a[i] < rate[j+1]:
            nums[j] = 1
    if a[i] >= 3200:
        tourist += 1

color = nums.count(1)

print(1 if color == 0 and tourist else color, color + tourist)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  bool flag = false;
  if(a + b == c) flag = true;
  if(b + c == a) flag = true;
  if(c + a == b) flag = true;
  
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3580
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), k = sc.nextInt();
        int[] x = new int[n];
        List<Integer> l = new ArrayList<>();
        List<Integer> r = new ArrayList<>();
        r.add(0);
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            if (x[i] >= 0) {
                r.add(x[i]);
            } else {
                l.add(x[i]);
            }
        }
        l.add(0);
        Collections.reverse(l);

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < k; i++) {
            int tmpr = Integer.MAX_VALUE, tmpl = Integer.MAX_VALUE;
            if (r.size() > i) {
                try {
                    tmpr = r.get(i) * 2 + Math.abs(l.get(k - i));
                } catch (IndexOutOfBoundsException ignored) {
                }
            }
            if (l.size() > i) {
                try {
                    tmpl = Math.abs(l.get(i)) * 2 + r.get(k - i);
                } catch (IndexOutOfBoundsException ignored) {
                }
            }
            ans = Math.min(Math.min(tmpr, tmpl), ans);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 97692