akhauriyash/Code-Regression huggingface dataset:
require 'set'
def score(n, a, c)
    reached = Set.new
    s = 0
    (0..n-1).each do |i|
        (0..i).each do |j|
            g = a[i][j]
            next if g == 0
            pos = [i, j]
            next if reached.include?(pos)
            dead = true
            k = 1

            stack = [pos]
            test = [pos]
            reached << pos
            until stack.empty?
                y, x = stack.pop
                [-1, 0, 1].repeated_permutation(2) do |dy, dx|
                    next if dy + dx == 0
                    y2, x2 = y + dy, x + dx
                    next if y2 < 0 || y2 > n-1 || x2 < 0 || x2 > y2
                    dead = false if a[y2][x2] == 0
                    next if a[y2][x2] != g
                    pos = [y2, x2]
                    next if reached.include?(pos)
                    stack << pos
                    reached << pos
                    k += 1
                    test << pos
                end
            end

            if dead
                s += (g == c ? -k : k)
            end
        end
    end
    s
end

loop do
    n, c = gets.split.map(&:to_i)
    break if n == 0

    a = (1..n).map { gets.split.map(&:to_i) }
    max = -Float::INFINITY

    (0..n-1).each do |i|
        (0..i).each do |j|
            next if a[i][j] != 0
            a[i][j] = c
            s = score(n, a, c)
            a[i][j] = 0
            max = s if s > max
        end
    end

    p max
end

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

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

// code starts
int main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  int i,j,k;
  int ans = 0;
  rep(i,n) cin >> l[i];
  rep(i,n)
  {
    for(j=i+1;j<n;j++)
    {
      for(k=j+1;k<n;k++)
      {
        if(l[i]==l[j]||l[j]==l[k]||l[k]==l[i]) continue;
        int maxl = max(l[i],max(l[j],l[k]));
        int left = -maxl+l[i]+l[j]+l[k];
        if(maxl < left) ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define int long long
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
typedef long long ll;
using namespace std;

int mypow(int a,int b){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1)*a%mod;
	return mypow(a,b/2)*mypow(a,b/2)%mod;
}
int kaijo(int n){
	int ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	f(i,c){
		if(i%2){
			b/=2;
			a+=b;
		}
		else{
			a/=2;
			b+=a;
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}


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


int main(){
    char S[20];
    scanf("%s",S);
    int i =0, flag =0;
/*
    if(strlen(S)%2 ==1){
        cout << "No" <<endl;
        return 0;
    } 
    while(S[i] != '\0'){
        if(S[i] == 'h' && S[i+1] == 'i'){
        }
        else{
            flag++; 
        }
        i= i+2;
    }
*/
    if(0 == strcmp(S,"hi")*strcmp(S,"hihi")*strcmp(S,"hihihi")*strcmp(S,"hihihihi")*strcmp(S,"hihihihihi")){
    cout << "Yes" << endl;        
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,n1,n2,n3,n4;
  cin >> n;
  n1 = n/1000;
  n2 = n%1000/100;
  n3 = n%100/10;
  n4 = n%10;
 
  if(n2==n3 && (n1==n2 || n3==n4))
  	cout << "Yes" << endl;
  else
  	cout << "No" << endl;
}

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

const long long mod = 1e9 + 7;

long long powmod(long long a, long long b) {
    long long c = 1;
    while(b > 0) {
        if(b & 1) {
            c = a * c % mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return c;
}

int main()
{
    long long n;
    cin >> n;
    long long ans = powmod(10, n) - powmod(9, n) * 2 + powmod(8, n);
    ans = (ans % mod + mod) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

struct dsu {
  vector<int> p;

  explicit dsu(int n) : p(n) {
    for (int i = 0; i < n; i++) p[i] = i;
  }

  void join(int a, int b) {
    a = get(a);
    b = get(b);
    p[a] = b;
  }

  int get(int a) {
    if (a == p[a]) return a;
    return p[a] = get(p[a]);
  }

};


bool solve(int n, int m, int q) {
  vector<pair<int, int>> bs;
  dsu d(n);
  for (int i = 0; i <q ; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (c == 0) {
      d.join(a, b);
    } else {
      bs.emplace_back(a, b);
    }
  }
  for (auto x : bs) {
    if (d.get(x.first) == d.get(x.second)) {
      return false;
    }
  }
  int comps = 0;
  for (int i = 0; i < n; i++) {
    if (d.get(i) == i) {
      comps++;
    }
  }
  if (comps < 3 && !bs.empty()) {
    return false;
  }

  ll min_edges = bs.empty() ? n - 1 : n;
  ll max_edges = (n - comps) + comps * 1LL * (comps - 1) / 2;
  return min_edges <= m && m <= max_edges;
}

int main() {
#ifdef LOCAL
  freopen("d.in", "r", stdin);
  freopen("d.out", "w", stdout);
#endif

  int n, m, q;
  while (scanf("%d%d%d", &n, &m, &q) == 3) {
    printf("%s\n", solve(n, m, q) ? "Yes" : "No");
  }


  return 0;
}


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

long long gcd(long long m, long long n)
{
	if (n == 0) return m;
	return gcd(n,m%n);
}



int main()
{
	int a1, a2, a3, m1, m2, m3, x, y, z;
	while (1)
	{
		cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
		if ((a1 | m1 | a2 | m2 | a3 | m3) == 0) { break; }

		long long cntx = 1, cnty = 1, cntz = 1, ans;
		x = a1 % m1;
		y = a2 % m2;
		z = a3 % m3;

		while (x != 1)
		{
			x = (a1 * x) % m1;
			cntx++;
		}
		while (y != 1)
		{
			y = (a2 * y) % m2;
			cnty++;
		}
		while (z != 1)
		{
			z = (a3 * z) % m3;
			cntz++;
		}

		ans = cntx * cnty / gcd(cntx, cnty);		//????????????????????°???????°???¬?????°????±???????
		ans = ans * cntz / gcd(ans, cntz);
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 1156
function main(arg) {
  arg = arg.split("\n");
  var arr = arg[1].split(" ").map(Number);
  var dp = [0, Math.abs(arr[1] - arr[0])]
  for (var i=2; i<arr.length; i++) {
    dp[i] = Math.min(Math.abs(arr[i] - arr[i-1]) + dp[i-1], Math.abs(arr[i] - arr[i-2]) + dp[i-2])
  }
  console.log(dp[dp.length-1])
}
main(require("fs").readFileSync("/dev/stdin", "utf8").trim()); 

Measured memory_bytes: 27584
l = [2, 1]
def a(N): 
    global l
    if(N == 0):
        return 2
    if(N == 1):
        return 1
    if(len(l) > N):
        return l[N]
    ans = a(N - 1) + a(N - 2)
    l.append(ans)
    return ans
    
N = input()
print a(N)

Measured memory_bytes: 2692
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[100005];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    scanf("%d", &l[i]);
  }
  int total = 0;
  for(int i = 1; i <= n+1; i++) {
    total += abs(l[i] - l[i-1]);
  }
  for(int i = 1; i <= n; i++) {
    int skip = abs(l[i+1] - l[i-1]) - abs(l[i+1] - l[i]) - abs(l[i] - l[i-1]);
    printf("%d\n", total + skip);
  }
}


Measured memory_bytes: 1664
//caddi2018_b.cpp
//Sat Dec 22 20:47:28 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,h,w;
	cin >> n >> h >> w;

	int a[n],b[n];
	int ans = 0;
	for (int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		if (a[i]>=h && b[i]>=w){
			ans++;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main () {
  string X, Y, answer;
  cin >> X >> Y;
  
  vector<string> data = {"A","B","C","D","E","F"};
  for (string a : data) {
    if (a == X && a != Y) {
      answer = '<';break;
    }
    if (a == Y && a != X) {
      answer = '>';break;
    }
    if (a == X && a == Y) {
      answer = '=';break;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

int a,b,d;
scanf("%d%d",&a,&b);
d=(a+b)/2;
if(a%2==0&&b%2==0||a%2!=0&&b%2!=0){printf("%d",d);}
else if(a%2==0&&b%2!=0||a%2!=0&&b%2==0)printf("IMPOSSIBLE");
return 0;
}

Measured memory_bytes: 128
H = []
W = []
while True:
    input_item = list(map(int, input().split()))
    if input_item == [0, 0]:
        break
    H.append(input_item[0])
    W.append(input_item[1])

for i in range(len(H)):
    h = H[i]
    w = W[i]
    print("#"*w)
    for _ in range(h-2):
        print("#" + "."*(w-2) + "#")
    print("#"*w)
    print()


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int n;
char s[200];
int main()
{
	int r=0;
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++) if(s[i]=='R') r++;
	if(r*2>n) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
D=[]
A=[]
DB=[0]*N

for k in range(K):
    D.append(int(input()))
    A.append(list(map(int,input().split())))

for a in A:
    for i in a:
        DB[i-1]+=1

ans=0

for db in DB:
    if db==0:
        ans+=1

print(ans)

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

int main(){
	int blueCount, redCount, max, now;
	string red[100], blue[100];

	cin >> blueCount;
	for(int i=0; i<blueCount; i++){
		cin >> blue[i];
	}
	cin >> redCount;
	for(int i=0; i<redCount; i++){
		cin >> red[i];
	}

	max=0;
	for(int i=0; i<blueCount; i++){
		now=0;
		for(int j=0; j<blueCount+redCount; j++){
			if(j<blueCount){
				if(blue[i]==blue[j]){
					now++;
				}
			}
			else{
				if(blue[i]==red[j-blueCount]){
					now--;
				}
			}
		}
		if(now>max){
			max=now;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define MOD 1000000007
int main(){
  struct UndirectedGraph{
    using Pint = pair<ll,ll>;
    using Plint = pair<ll,ll>;
    ll V;
    ll E;
    ll dDefault;
    vector<ll> weights;
    vector<vector<Pint>> to;
    vector<Pint> edges;
 
    UndirectedGraph(ll V, ll dDefault=-1) : V(V), E(0), dDefault(dDefault),
                             to(vector<vector<Pint>>(V)) {}
 
    void add_edge(ll v1,ll v2, ll w)
    {
        to[v1].push_back(Pint(v2, E));
        // to[v2].push_back(Pint(v1, E));
        edges.push_back(Pint(v1, v2));
        weights.push_back(w);
        E++;
    }
 
    vector<ll> dist;
    void dijkstra(ll start)
    {
        dist = vector<ll>(V, dDefault);
        priority_queue<Plint, vector<Plint>, greater<Plint>> pq;
        pq.push(Plint(0, start));
 
        while (!pq.empty()) {
            Plint p = pq.top(); pq.pop();
            ll v = p.second;
            if (dist[v] >= 0 && dist[v] <= p.first) continue;
            dist[v] = p.first;
            // cout << "dist[" << v << "] = " << p.first << endl;
            for (auto vnxt : to[v]) {
                 ll dnxt = dist[v] + weights[vnxt.second];
                if (dnxt < dist[vnxt.first] || dist[vnxt.first] < 0) {
                    pq.push(Plint(dnxt, vnxt.first));
                }
            }
        }
    }
};
  ll n,m,a,b;cin>>n>>m;
  UndirectedGraph graph(n*3+9);
  rep(i,m){
    cin>>a>>b;a--;b--;
    graph.add_edge(a*3,b*3+1,1);
    graph.add_edge(a*3+1,b*3+2,1);
    graph.add_edge(a*3+2,b*3,1);
  }
  ll s,t;cin>>s>>t;s--;t--;
  graph.dijkstra(s*3);
  ll answer=graph.dist[t*3];
  cout<<(answer%3?-1:answer/3)<<endl;
}

Measured memory_bytes: 29032
#include <stdio.h>

int main(void)
{
	int i = 1, x;
	
	while (1) {
		scanf("%d", &x);
		if(x == 0) {
			break;
		}
		printf("Case %d: %d\n", i, x);
		i++;
	}
	
	return 0;
}

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

bitset<4000001> dp;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	dp[0]=1;
	int n;
	cin>>n;
	int tot=0;
	for(int i=1,x;i<=n;i++){
		cin>>x;
		tot+=x;
		dp|=dp<<x;
	}
	for(int i=(tot+1)/2;;i++)
		if(dp[i]){
			cout<<i<<endl;
			return 0;
		}
	
}


Measured memory_bytes: 1792
N = int(input())
S = input()
a = [0] * N
b = [0] * N
counter = []

if S[0] == '#':
    a[0] = 1
if S[N-1] == '.':
    b[N-1] = 1

for i in range(N-1):
    if S[i+1] == '#':
        a[i+1] = a[i] + 1
    else:
        a[i+1] = a[i]
    if S[N-i-2] =='.':
        b[N-i-2] = b[N-i-1] + 1
    else:
        b[N-i-2] = b[N-i-1]
counter.append(a[N-1])
counter.append(b[0])
for i in range(N-1):
    counter.append(a[i] + b[i+1])

print(min(counter))

Measured memory_bytes: 20968
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll X, ans=0, a;

    cin >> X;

    a = X/500;
    ans += a*1000;

    X -= a*500;

    a = X/5;
    ans += a*5;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*Saidur Rahman Sajol:A weirdo*/
  /*Dept. of CSE,IUBAT(162)*/
/*---------------------------*/

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

#define ll             long long
#define l              long
#define ul             unsigned long
#define ull            unsigned long long
ull minimum(ull a,ull b){
  return (a<b)?a:b;
}
ull maximum(ull a,ull b){
  return (a>b)?a:b;
}

int main() {
   ull t;
   cin>>t;
   ull m;
   int x=0;
   while(t--){
	   ull a,b;
	   cin>>a>>b;
	   if(x<a){
		   x=a;
		   m=b;
   }
}
 //  cout<<x<<" "<<m<<endl;
   cout<<m+x<<endl;
  return 0;
}


Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

  cout << (n - 1) * (m - 1) << endl;
  
  return 0;
}

Measured memory_bytes: 3636
import sys

N = int(input())
a = [[int(i) for i in input().split()] for i in range(N)]

a_sorted = sorted(a, key=lambda x: x[1])

s = 0
for t in range(N):
  s+=a_sorted[t][0]
  if s > a_sorted[t][1]:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 42832
#include <iostream>
#include<math.h>
#include <vector>

using namespace std;


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    // 昇順
    //sort(a.begin(), a.end());

    // 降順
    sort(a.begin(), a.end(), [](const int x, const int y) { return x > y; });
    // sort(a.begin(), a.end(), greater<int>());  // a[0:N] を大きい順にソート

    int alice = 0;
    int bob = 0;
    for (int j = 0; j < N; ++j) {
        if (j % 2 == 0) {
            alice += a[j];
        } else {
            bob += a[j];
        }
    }

    cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#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 ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=7;
int h, w, k;
string s[L];
ll get(ll x, ll y)
{
	set<int>rr, cc;
	int co = 0;
	while(x>0)
	{
		if(x&1)rr.insert(co);
		x>>=1;
		co++;
	}
	co = 0;
	while(y>0)
	{
		if(y&1)cc.insert(co);
		y>>=1;
		co++;
	}
	int ret = 0;
	FOR(i,0,h)
	{
		FOR(j,0,w)
		{
			if(rr.find(i) == rr.end() && cc.find(j)==cc.end() && s[i][j] == '#')ret++;
		}
	}
	return ret == k;
}
void fff()
{
	cin >> h >> w >> k;
	FOR(i,0,h)cin >> s[i];
	ll ans = 0;
	FOR(i,0,(1<<h))
	{
		FOR(j,0,(1<<w))
		{
			ans += get(i,j);
		}
	}
	cout << ans<<ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>
int bomb[8][8];
void fire(int i,int j){
	int k;
	bomb[i][j]=0;
	for(k=(i<3?0:i-3);k<(i>4?8:i+4);k++)if(bomb[k][j])fire(k,j);
	for(k=(j<3?0:j-3);k<(j>4?8:j+4);k++)if(bomb[i][k])fire(i,k);
}
int main(void){
	int i,j,n,x;
	scanf("%d",&n);
	for(x=1;x<=n;x++){
		printf("Data %d:\n",x);
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				scanf("%1d",&bomb[i][j]);
			}
		}
		scanf("%d %d",&j,&i);
		fire(i-1,j-1);
		for(i=0;i<8;i++){
			for(j=0;j<8;j++){
				printf("%d",bomb[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}

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

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

    int a[1000000] = {};
    for (int i = 0; i < n; i++) {
        int idx;
        cin >> idx;

        a[idx]++;
        a[idx + 1]++;
        a[idx - 1]++;
    }
    sort(a, a + 1000000);
    cout << a[999999] << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
long long  int_pow(int base,int power){
    int ret = 1;
    for(int i=0;i<power;i++){
        ret *=base;
    }
    return ret ;
}

int get_highest_bit(int N){
    //最大の桁数を返す
    int  i = 0;
    long long highest_representable = 0;
    long long  lowest_representable = 0;
    while(1){
        if (i%2 == 0){
            highest_representable += int_pow(-2,i);
        }else{
            lowest_representable += int_pow(-2,i);
        }
        if (lowest_representable<=N && N<=highest_representable){
            return i+1;
        }
        i++;
    }
}
void print_ans(int* ans){
    int maximum_bit = 1;
    for (int i =1;i<=100;i++){
        if (ans[i-1] == 1) maximum_bit = i;
    }
    for (int i = 0;i<maximum_bit;i++){
        printf("%d",ans[maximum_bit-1-i]);
    }
    printf("\n");

}

void solve(long long N){
    int res_N = N;
    int ans[100] = {0};
    while(1){
        int j = get_highest_bit(res_N);
        if (j == 1){
            ans[0] = res_N;
            break;
        }else{
            res_N = res_N - int_pow(-2,j-1);
            ans[j-1] = 1;
        }
        
    }
    print_ans(ans);

    

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
// Bismillahir Rahmanir Rahim
// AtCoder-Golden Coins


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

int main(){
	long long X,A1,A2,B,ans;
	cin>>X;
	A1 = X/500; A2 = X%500;
	B = A2/5;
	ans = A1*1000+B*5;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,d,x[20][20],ans=0;

int main()
{
	cin>>n>>d;
	rep(i,n) rep(j,d) cin>>x[i][j];
	rep(i,n)
	{
		for(int j=i+1;j<n;j++)
		{
			int res=0;
			rep(k,d) res+=sqr(x[i][k]-x[j][k]);
			rep(k,200) if(sqr(k)==res) ans++;
		}
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c[100],i; 
int main()
{
	scanf("%d%d",&a,&b);
	c[a]=1;c[b]=1;
	for(i=1;i<=3;++i)
	{
		if(!c[i])
		{
		    printf("%d",i);	
		    return 0;
		}
	}
}

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

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt();
		boolean[] row = new boolean[H]; Arrays.fill(row, false);
		boolean[] col = new boolean[W]; Arrays.fill(col, false);
		char[][] a = new char[H][W];
		for(int i = 0; i < H; i++) {
			String s = sc.next();
			for(int j = 0; j < W; j++) a[i][j] = s.charAt(j);
		}
		/* look at i-th row */
		for(int i = 0; i < H; i++) {
			boolean check = true;
			for(int j = 0; j < W; j++) if(a[i][j] == '#') check = false;
			row[i] = check;
		}
		/* look at j-th col */
		for(int j = 0; j < W; j++) {
			boolean check = true;
			for(int i = 0; i < H; i++) if(a[i][j] == '#') check = false;
			col[j] = check;
		}
		for(int i = 0; i < H; i++) {
			if(row[i]) continue;
			for(int j = 0; j < W; j++) {
				if(col[j]) continue;
				System.out.print(a[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 22100
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    if n % 2 == 0:
        print(n//2 - 1)
    else:
        print(n//2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll
int n;
string s[111];

signed main(){
    bool can=true;
    cin>>n;
    rep(i,0,n){
        cin>>s[i];
        if(i!=0){
            if(s[i-1][s[i-1].size()-1]!=s[i][0])can=false;
            //cout<<s[i-1][s[i-1].size()-1]<<endl;
        }
    }
    rep(i,0,n)rep(j,0,n){
        if(i==j)continue;
        if(s[i]==s[j])can=false;
    }
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main() {
 int n,T,cost=1001;cin>>n>>T;int c[n];int t[n];
  
for(int i=0;i<n;i++){
  cin>>c[i]>>t[i];
  if(t[i]<=T && c[i]<cost) cost=c[i];

}
  if(cost==1001)cout<<"TLE"<<endl;
else cout<<cost<<endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int64_t N;
  cin >> N;
  int64_t sum = 0;
  for (int64_t i = 1; i <= N; i++) {
    if (i%3 != 0 && i%5 != 0) {
      sum += i;
    }
    else {
      continue;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3156
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  tmp = input[1].split(" ");
  a=new Array(n).fill(0);
  for(i=0;i<n;i++){
    a[i]=parseInt(tmp[i]);
  }
  var odd=0;
  var four=0;
  for(i=0;i<n;i++){
    if(a[i]%2==1){
      odd++;
    }else if(a[i]%4==0){
      four++;
    }
  }
  var ans="No";
  if(odd==0){
    ans="Yes";
  }else if(odd-four<=0){
    ans="Yes";
  }else if(n%2==1&&odd-four<=1&&four>0){
    ans="Yes";
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17484
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

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

int main(){

	string str;
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		int** mat = new int*[n+1];
		for(int i=0;i<n+1;i++) mat[i] = new int[n+1];
		for(int y=0;y<n;y++){
			for(int x=0;x<n;x++){
				int num;
				scanf("%d",&num);
				mat[y][x] = num;
			}
		}

		int sum=0;
		int col=0;
		for(int y=0;y<n;y++){
			for(int x=0;x<n;x++){
				col += mat[y][x];
			}
			mat[y][n]=col;
			sum+=col;
			col=0;
		}

		int row=0;
		for(int x=0;x<n;x++){
			for(int y=0;y<n;y++){
				row += mat[y][x];
			}
			mat[n][x]=row;
			row=0;
		}

		mat[n][n] = sum;

		for(int y=0;y<=n;y++){
			for(int x=0;x<=n;x++){
				printf("%5d%s",mat[y][x],x==n ? "\n" : "");
			}
		}

		for(int i=0;i<n+1;i++) delete[] mat[i];
		delete[] mat;
	}
}

Measured memory_bytes: 0
n, m, x = map(int, input().split())

c = [0] * n
a = [[] for _ in range(n)]

for i in range(n):
    ca = list(map(int, input().split()))
    c[i], a[i] = ca[0], ca[1:]

ans = INF = 1e+9

for s in range(1 << n):
    skill = [0] * m
    money = 0
    for i in range(n):
        # don't buy a book
        if (s >> i) % 2 == 0:
            continue
        money += c[i]
        for j in range(m):
            skill[j] += a[i][j]
    flag = 1
    for k in range(m):
        if skill[k] < x:
            flag = 0
    if flag:
        ans = min(ans, money)
if ans == INF:
    ans = -1

print(ans)

Measured memory_bytes: 9096
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) { cin >> A[i]; }

    bool dp[K + 1]; //残りK個の時の勝ち負け
    memset(dp, false, sizeof(dp));
    dp[0] = false;

    for (int i = 0; i <= K; i++) {
        for (int j = 0; j < N; j++) {
            if (i - A[j] >= 0)
                dp[i] |= !dp[i - A[j]];
        }
    }

    cout << (dp[K] ? "First" : "Second") << endl;
}

Measured memory_bytes: 3736
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,t=LI()
  l=LI()

  sm=0
  for i in range(n-1):
    a=l[i]
    b=l[i+1]

    if b-a>t:
      sm+=t
    else:
      sm+=b-a

  return sm+t

print(main())


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

class Program
{
    static long N;

    public static void Main(string[] args)
    {
        N = Input.NextLong();

        long ans = 0;
        for (int i = 1; i < N; i++)
        {
            long a = (N - i) / i;
            if (i >= a)
                break;
            long a_mod = (N - i) % i;
            if (a_mod == 0)
            {
                ans += a;
            }
        }
        
        Console.WriteLine(ans);
    }
} 

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

int main(void){
	int A,B;
	cin >> A >> B;
	for(int i=1;i<=1000;i++){
		if((i*8)/100==A && (i/10)==B){
		 cout << i <<endl;
		 return 0;
		}
	}
	cout << -1<<endl;
return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;

namespace Kyopuro1ads
{
    class Program
    {
        static void Main(string[] args)
        {

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            int N = int.Parse(Console.ReadLine());      
            string[] str = Console.ReadLine().Split(' ');
            int i,j;
            int[] num = new int[N];

            for (i = 0; i < N; i++)
            {
                num[i] = int.Parse(str[i]);
            }

            int min = 2000000000;
            int temp=0;
            for (i = 1; i < 101; i++)
            {
                temp = 0;
                for (j = 0; j < N; j++)
                {
                    temp = temp + ((num[j] - i) * (num[j] - i));
                }
                if(temp < min)
                {
                    min = temp;
                }
            }

            Console.WriteLine(min);









            //Console.WriteLine((int)Math.Ceiling(Math.Log(N+1,K)));


            //  int N = int.Parse(Console.ReadLine());
            //  string[] str = Console.ReadLine().Split(' ');
            //  int i;
            //  int[] num = new int[N];
            //
            //  for (i = 0; i < N; i++)
            //  {
            //      num[i] = int.Parse(str[i]);
            //  }


            Console.Out.Flush();
        }





    }


}


Measured memory_bytes: 11092
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <queue>
#include <vector>

using namespace std;

int main() {
  int d;
  while (scanf("%d", &d) == 1) {
    int a = 0;
    for (int x = 0; x < 600; x += d)
      a += d * x * x;
    printf("%d\n", a);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
 #define MOD ((int)1e9+7)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 

 
const int N=2e5+100;
ll visited[100005];
//ll a[200000];
 

#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;

int dx[4] = {1 , 0 , 0 , -1} ;
int dy[4] = {0 , 1 , -1 , 0} ;

const int MAX = 2e5 + 10 ;
void finis(){cout<<-1;}
vector<pair<int,int>>v;

int a[3001][100];ll h,w;
int valid(ll x,ll y){
    if(x<=0||x>h||y<=0||y>w||a[x][y]==1){return 0;}
    return 1;
}ll ans[100][100];
int main()
{  ios::sync_with_stdio(0);
cin.tie(0);
cin>>h>>w;ll lol=0;
for(int i=1;i<=h;i++){
   for(int j=1;j<=w;j++){
       char xx;cin>>xx;if(xx=='#'){ lol++;a[i][j]=1;}ans[i][j]=10000007;
       
   }
}queue<pair<ll,ll>>q;ans[1][1]=0;
q.push({1,1});
while(!q.empty()){
    pair<ll,ll>l=q.front();
    q.pop();
    ll x=l.first;ll y=l.second;
    ll myans=ans[x][y];
    for(int j=0;j<4;j++){
        ll xx=x+dx[j];
        ll yy=y+dy[j];
        if(valid(xx,yy)&&myans+1<ans[xx][yy]){
            q.push({xx,yy});ans[xx][yy]=myans+1;
        }
    }
}if(a[1][1]||a[h][w]||ans[h][w]==10000007){cout<<-1;return 0;}
cout<<(h*w)-(ans[h][w]+1)-lol;

   
}


Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(0, i, N)
    {
        cin >> A.at(i);
    }
    rep(0, i, N)
    {
        cin >> B.at(i);
    }
    vector<int> sum1(N, A.at(0)), sum2(N, B.at(N - 1));
    rep(1, i, N)
    {
        sum1.at(i) = sum1.at(i - 1) + A.at(i);
    }
    rep(1, i, N)
    {
        sum2.at(i) = sum2.at(i - 1) + B.at(N - i - 1);
    }
    reverse(all(sum2));
    int ans = 0;
    rep(0, i, N)
    {
        ans = max(ans, sum1.at(i) + sum2.at(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int inputSec ,outS,outM,outH= 0;
            inputSec=int.Parse(Console.ReadLine());

            outH = inputSec / 3600;
            outM = (inputSec % 3600) / 60;
            outS = (inputSec % 3600) % 60;

            Console.WriteLine(outH + ":" + outM + ":" + outS);
           
        }
    }
}



Measured memory_bytes: 17996
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;
#define W 0
#define S 1
int C[101][101][2][2];
int main()
{
    int w,h;
    for(int i=1;i<101;++i)
    {
        C[i][1][S][0] = 0;
        C[i][1][W][0] = 1;
        C[i][1][S][1] = 0;
        C[i][1][W][1] = 0;
        C[1][i][S][0] = 1;
        C[1][i][W][0] = 0;
        C[1][i][S][1] = 0;
        C[1][i][W][1] = 0;
    }
    for(int i=2;i<101;++i){
        for(int j=2;j<101;++j){
            C[i][j][W][0] = (C[i-1][j][W][0]+C[i-1][j][W][1])%100000;
            C[i][j][S][0] = (C[i][j-1][S][0]+C[i][j-1][S][1])%100000;
            C[i][j][W][1] = (C[i-1][j][S][0])%100000;
            C[i][j][S][1] = (C[i][j-1][W][0])%100000;
        }
    }
    while(cin >> w >> h && w && h)
    {
        cout << (C[w][h][W][0]+C[w][h][W][1]+C[w][h][S][0]+C[w][h][S][1])%100000 << endl;
    }
}

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

int main()
{
  int x;
  cin>>x;
  if(x%10==3) cout<<"bon"<<endl;
  else if(x%10==0||x%10==1||x%10==6||x%10==8)
    cout<<"pon"<<endl;
  else cout<<"hon"<<endl;



    return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		for(int i = 1; i <=3000; i++){
			String inputData = br.readLine();
			String[] inputValue = inputData.split(" ");

			int x = Integer.parseInt(inputValue[0]);
			int y = Integer.parseInt(inputValue[1]);

			if(x == 0 && y == 0){
				break;
			}else{
				int[] outputValue = {x, y};
				Arrays.sort(outputValue);
				System.out.println(outputValue[0] + " " + outputValue[1]);
			}
		}
	}

}

Measured memory_bytes: 27436
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll a[3],i;
	ll b[3];
	ll c[4];
	fr(i,0,4)
		c[i] = 0;
	fr(i,0,3)
	{
		cin >> a[i] >> b[i];
		c[a[i] - 1]++;
		c[b[i] - 1]++;
	}
	sort(c,c+4);
	if((c[0] == 1)&&(c[1] == 1)&&(c[2] == 2)&&(c[3] == 2))
		cout << "YES";
	else
		cout << "NO";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int f;
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
		if(s[i]=='C') f=1;
		if(f==1 && s[i]=='F') f=2;
	}
	if(f==2) cout<<"Yes";
	else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
void main() {
    int[] tmp = readln.split.to!(int[]);
    int w = tmp[0], h = tmp[1], n = tmp[2];
    int[] x = new int[n], y = new int[n], a = new int[n];
    foreach (i; 0 .. n) {
        tmp = readln.split.to!(int[]);
        x[i] = tmp[0], y[i] = tmp[1], a[i] = tmp[2];
    }
    int xmin, xmax = w, ymin, ymax = h;
    foreach (i; 0 .. n) {
        if (a[i] == 1) {
            xmin = max(xmin, x[i]);
        } else if (a[i] == 2) {
            xmax = min(xmax, x[i]);
        } else if (a[i] == 3) {
            ymin = max(ymin, y[i]);
        } else {
            ymax = min(ymax, y[i]);
        }
    }
    writeln(max(0, xmax-xmin) * max(0, ymax-ymin));
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

using namespace std;

#define ull unsigned long long
#define ll long long
#define ld long double

#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define MX LLONG_MAX
#define MN LLONG_MIN

const ll mod=1e9+7;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

int32_t main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll N = 2005;
    ll arr[N][N];
    for(ll i=0;i<N;i++)
    {
        for(ll j=0;j<N;j++)
            arr[i][j] = 0;
    }
    for(ll i=0;i<N;i++)
        arr[i][0] = 1;
    arr[1][1] = 1;
    for(ll i=2;i<N;i++)
    {
        for(ll j=1;j<=(i+1);j++)
            arr[i][j] = (arr[i-1][j]+arr[i-1][j-1]) % mod;
    }
    for(ll i=1;i<=k;i++)
    {
        ll ans = (arr[n-k+1][i] * arr[k-1][i-1] ) % mod;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 31616
int main()
{
  long a, b, v, w, t;
  scanf("%ld %ld", &a, &v);
  scanf("%ld %ld", &b, &w);
  scanf("%ld", &t);
  if (v <= w)
  {
    printf("NO");
    return 0;
  }
  long dis;
  if (a > b)
    dis = abs(a-b);
  else
    dis = abs(b-a);
  if (dis - t * (v - w) > 0)
    printf("NO");
  else
    printf("YES");
}

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

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

  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N - 1);
  for (int i = 0; i < N; ++i) {
    cin >> A.at(i);
    A.at(i)--;
  }
  for (int i = 0; i < N; ++i) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N - 1; ++i) {
    cin >> C.at(i);
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += B.at(A.at(i));
    if (i > 0 && A.at(i) == A.at(i - 1) + 1) {
      ans += C.at(A.at(i - 1));
    }
  }

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


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    string a, b;
    cin >> a >> b;
    if (a == "H")cout << b << endl;
    else {
        if (b == "D")cout << "H" << endl;
        else cout << "D" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
# code-festival-2016-qualcC - 二人のアルピニスト / Two Alpinists
from bisect import bisect_left as bs


def main():
    """
      /----\     <- xi (= yi)
     /      \--\
    /           \
      xi  yi
    0 ~ xi / xi ~ yi / yi+1 ~ N-1
    """
    N = int(input())
    T = tuple(map(int, input().split()))
    A = tuple(map(int, input().split()))
    x, y, xi, yi = 0, 0, 0, 0  # max of x, y and the indices
    for i, t in enumerate(T):
        if t > x:
            x, xi = t, i
    for i, a in enumerate(A):
        if a >= y:
            y, yi = a, i
    if x != y or xi > yi:
        print(0)
        return
    MOD = 10 ** 9 + 7
    ans, cur = 1, 0
    for i in T[: xi + 1]:
        if i > cur:  # point of new altitude -> no choice (ans * 1)
            cur = i
        else:
            ans = (ans * cur) % MOD  # mulitple choices (1, 2, ..., cur)
    for _ in range(xi + 1, yi):
        ans = (ans * cur) % MOD
    for i in A[yi + 1 :]:
        if i < cur:
            cur = i
        else:
            ans = (ans * cur) % MOD
    print(ans)


if __name__ == "__main__":
    main()

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

int main(){
	int n=0;
	int a[10000];
	a[0] =1;
	while(a[n] != 0){
		n++;
		cin >> a[n];
	}
	for(int i=1; i<n; i++){
		cout << "Case " << i << ": " << a[i] << endl;
	}
}  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, b;
    cin >> a >> b;
    cout << (((b - 1) + (a - 2)) / (a - 1)) << endl;
    return 0;
}


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

int main() {
  long q,query,a,b,nowans2=0;
  cin >> q;
  multiset<long> adata;
  vector<long> ans1,ans2;

  cin >> query >> a >> b;
  adata.insert(a);
  auto itr=adata.begin();
  nowans2+=b;

  for(long i=1;i<q;i++) {
    cin >> query;
    if(query==1) {
      cin >> a >> b;
      nowans2+=b;
      if(adata.size()%2==0) {
        long aaa=*(itr);
        itr++;
        long bbb=*(itr);
        itr--;
        adata.insert(a);
        if(a<aaa) nowans2+=aaa-a;
        else if(a>bbb) nowans2+=a-bbb;
        if(a>=aaa) itr++;
      } else {
        adata.insert(a);
        nowans2+=labs(a-*(itr));
        if(a<*(itr)) itr--;
        
      }
    } else {
      ans1.push_back(*(itr));
      ans2.push_back(nowans2);
    }
  }
  for(long i=0;i<ans1.size();i++) cout << ans1[i] << " " << ans2[i] << endl;
}

Measured memory_bytes: 12908
import sys
N = int(input())
S = [int(input()) for _ in range(N)]

total = sum(S)
if total % 10 != 0:
  print(total)
else:
  S = sorted(S)
  for i in S:
    if i % 10 != 0:
      print(total-i)
      break
  else:
    print('0')

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

int main(){
  int n;
  cin >> n;
  int d[100];
  int save[101]={0};
  int ans=0;
  for(int i=0;i<n;i++) cin >> d[i];
  
  for(int i=0;i<n;i++){
    save[d[i]]++;
  }
  
  for(int i=1;i<=100;i++){
    if(save[i]>0) ans++;
  }
  
  cout << ans <<endl;
}

  
  


Measured memory_bytes: 256
n,yen = map(int, input().split())
x,y,z = yen//10000, yen//5000, yen//1000
for i in range(x+1):
  for j in range(y+1):
    h = n-i-j
    if h < 0 or h > z:
      continue
    if i*10000+j*5000+h*1000==yen:
      print(i,j,h)
      exit()
print(-1,-1,-1)

Measured memory_bytes: 9180
A,B,C=list(map(int,open(0).read().split()))
modlist=[A%B]
i=2

#あまりのリストを生成
while True:
    divd=A*i
    if divd%B==A%B:
        break
    modlist.append(divd%B)
    i=i+1

for j in modlist:
    if j==0:
        continue
    if C%j==0:
        print('YES')
        break
    else:
        C=C%j
else:
    print('NO')

Measured memory_bytes: 9192