akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var min = int.MaxValue;
        for (int a = 1; a < n; a++)
        {
            var b = n - a;
            var sum = (a.ToString() + b.ToString()).Sum(c => int.Parse(c.ToString()));
            min = Math.Min(sum, min);
        }

        Console.WriteLine(min);
    }
}

Measured memory_bytes: 15424
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0)
p=*0..gets.to_i;s=0;
f=->a{a==p[a]?a: p[a]=f[p[a]]}
a,b=$<.map(&:split).transpose.map{|a|i=0;a.map{|a|[a.to_i,i+=1]}.sort.each_cons(2).map{|(x,i),(y,j)|[y-x,i,j]}};
(a+b).sort_by{|a|a[0]}.map{|c,a,b|(s+=c;p[p[b]]=p[a])if f[a]!=f[b]}
p s

Measured memory_bytes: 106216
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  unsigned long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n + 10, 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int x = 1, i = k + 1; i <= n; i++, x++) {
        if (a[i] > a[x]) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 4836
#include <cstdio>
#define orz 1000000007
using namespace std;
int n,a[2005];
long long b[2005];
int main(void){
	int i,j;
	long long ans=0,k,cnt,re=0;
	scanf("%d%lld",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++){
		for(j=0,cnt=0;j<n;j++){
			if(a[j]<a[i]){
				cnt++;
				if(i<j) b[i]++;
			}
		}
		ans=(ans+cnt)%orz;
		re=(re+b[i])%orz;
	}
	re=re*k%orz;
	k=((k-1)*k/2)%orz;
	ans=ans*k%orz;
	ans=(ans+re)%orz;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int n;
    cin>>n;
    if(n==3||n==5||n==7){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vvl dp(h + 1, vl(w, 0));
    dp[0][0] = 1;
    vl cases(8, 0);
    cases[0] = 1;
    for (int i = 1; i <= 7; ++i) {
        for (int j = 0; j < 1 << i; ++j) {
            bool valid = true;
            for (int k = 0; k < i - 1; ++k) {
                if ((j & 1 << k) && (j & 1 << (k + 1))) {
                    valid = false;
                    break;
                }
            }
            if (valid)
                cases[i]++;
        }
    }
    for (int i = 1; i <= h; ++i) {
        for (int j = 0; j < w; ++j) {
            ll tempmid = dp[i - 1][j];
            if (j > 1)
                tempmid = tempmid * cases[j - 1] % MOD;
            if (j < w - 2)
                tempmid = tempmid * cases[w - (j + 2)] % MOD;
            ll templeft = 0;
            ll tempright = 0;
            if (j > 0) {
                templeft = dp[i - 1][j - 1];
                if (j > 2)
                    templeft = templeft * cases[j - 2] % MOD;
                if (j < w - 2)
                    templeft = templeft * cases[w - (j + 2)] % MOD;
            }
            if (j < w - 1) {
                tempright = dp[i - 1][j + 1];
                if (j > 1)
                    tempright = tempright * cases[j - 1] % MOD;
                if (j < w - 3)
                    tempright = tempright * cases[w - (j + 3)] % MOD;
            }
            dp[i][j] = (tempmid + templeft + tempright) % MOD;
        }
    }
    cout << dp[h][k - 1] << endl;
    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int n , x;

int main()
{
    _FastIO;
    cin >> n;
    set<int> s;
    for(int i = 0; i < n; i++){
        cin >> x;
        s.insert(x);
    }
    cout << s.size() << endl;
    return 0;
}


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

n=int(input())
s = list(map(int,input().split()))
cnt=0

for i in range(n-2):
    if((s[i]<s[i+1] and s[i+1]<s[i+2])or(s[i]>s[i+1] and s[i+1]>s[i+2])):
        cnt+=1

print(cnt)

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

int main(){
  constexpr int inf=100000000;
  int n,m;
  std::cin>>n>>m;
  
  int a[1010],b[1010],c[1010],dist[1010][1010];
  for(int i=0;i<m;++i){
    std::cin>>a[i]>>b[i]>>c[i];
    --a[i],--b[i];
  }
  
  for(int i=0;i<n;++i)
    for(int j=0;j<n;++j)
      if(i==j)
        dist[i][j]=0;
      else
        dist[i][j]=inf;
  
  for(int i=0;i<m;++i){
    dist[a[i]][b[i]]=std::min(dist[a[i]][b[i]],c[i]);
    dist[b[i]][a[i]]=std::min(dist[b[i]][a[i]],c[i]);
  }
  
  for(int k=0;k<n;++k)
    for(int i=0;i<n;++i)
      for(int j=0;j<n;++j)
        dist[i][j]=std::min(dist[i][j],dist[i][k]+dist[k][j]);
    
  int ans=m;
  for(int i=0;i<m;++i){
    bool shortest=false;
    for(int j=0;j<n;++j)
      if(dist[j][a[i]]+c[i]==dist[j][b[i]])
        shortest=true;
    if(shortest)
      ans-=1;
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();
            int[] h = new int[N];
            for (int i = 0; i < N; i++) {
                h[i] = in.nextInt();
            }

            int count = 0;
            for (int i = 0; i < N; i++) {
                if (h[i] >= K) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 49412
#include<iostream>

using namespace std;

int main(){
    int n, a, b, c, d;

    cin >> n;

    if(n == 100000){
        a = 1, b = 1, c = 1, d = 0;
    }
    else if(n >= 10000){
        a = 1, b = 1, c = 0, d = n - 9999;
    }
    else if(n >= 1000){
        a = 1, b = 1, c = 0, d = 0;
    }
    else if(n >= 100){
        a = 1, b = 0, c = 0, d = n - 99;
    }
    else if(n >= 10){
        a = 1, b = 0, c = 0, d = 0;
    }
    else{
        a = 0, b = 0, c = 0, d = n;
    }
    cout << a * 9 + b * 900 + c * 90000 + d << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int l, a, b, c, r, t, sum = 0;
	scanf("%d", &l);
	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= l; j++) {
			for (int k = 1; k <= l; k++) {
				a = i;
				b = j;
				c = k;
				if (a < b) {
					t = a;
					a = b;
					b = t;
				}
				r = a%b;
				while (r != 0) {
						a = b;
						b = r;
						r = a%b;
				}
				if (b < c) {
						t = b;
						b = c;
						c = t;
				}
				r = b%c;
				while (r != 0) {
					b = c;
					c = r;
					r = b%c;
				}
				sum = sum + c;
			}
		}
	}
	printf("%d", sum);
}

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

typedef long long ll;
const int INF = 1e9 + 5;


bool comp(const tuple<pair<ll, int>, pair<ll, int>, pair<ll, int>>& t1, const tuple<pair<ll, int>, pair<ll, int>, pair<ll, int>>& t2) {
	int t1s = get<0>(t1).first + get<1>(t1).first + get<2>(t1).first;
	int t2s = get<0>(t2).first + get<1>(t2).first + get<2>(t2).first;
	return t1s < t2s;
}

int main() {
	ios_base::sync_with_stdio(false);
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> A(x), B(y), C(z);
	for (int i = 0; i < x; i++) cin >> A[i];
	for (int i = 0; i < y; i++) cin >> B[i];
	for (int i = 0; i < z; i++) cin >> C[i];
	sort(A.begin(), A.end(), greater<ll>()); 
	sort(B.begin(), B.end(), greater<ll>());
	sort(C.begin(), C.end(), greater<ll>());
	auto cmp = [](tuple<pair<ll, int>, pair<ll, int>, pair<ll, int>> t1, tuple<pair<ll, int>, pair<ll, int>, pair<ll, int>> t2) 
	{ 
		ll t1s = get<0>(t1).first + get<1>(t1).first + get<2>(t1).first;
		ll t2s = get<0>(t2).first + get<1>(t2).first + get<2>(t2).first;
		return t1s < t2s;
	};
	priority_queue<tuple<pair<ll, int>, pair<ll, int>, pair<ll, int>>, vector<tuple<pair<ll, int>, pair<ll, int>, pair<ll, int>>>, decltype(cmp)> pq(cmp);
	map<tuple<int, int, int>, int> visited;

	visited[make_tuple(0, 0, 0)] = 1;
	pq.push(make_tuple(make_pair(A[0], 0), make_pair(B[0], 0), make_pair(C[0], 0) ));
	for (int i = 0; i < k; i++) {
		pair<ll, int> a, b, c;
		tie(a, b, c) = pq.top(); pq.pop();
		cout << a.first + b.first + c.first << endl;
	
		if (!visited[make_tuple(a.second + 1, b.second, c.second)] && a.second != x - 1) {
			visited[make_tuple(a.second + 1, b.second, c.second)] = 1;
			pq.push(make_tuple(make_pair(A[a.second + 1], a.second + 1), make_pair(B[b.second], b.second), make_pair(C[c.second], c.second) ));
		}
		if (!visited[make_tuple(a.second, b.second + 1, c.second)] && b.second != y - 1) {
			visited[make_tuple(a.second, b.second + 1, c.second)] = 1;
			pq.push(make_tuple(make_pair(A[a.second], a.second), make_pair(B[b.second + 1], b.second + 1), make_pair(C[c.second], c.second)));
		}
		if (!visited[make_tuple(a.second, b.second, c.second + 1)] && c.second != z - 1) {
			visited[make_tuple(a.second, b.second, c.second + 1)] = 1;
			pq.push(make_tuple(make_pair(A[a.second], a.second), make_pair(B[b.second], b.second), make_pair(C[c.second + 1], c.second + 1)));
		}
	}
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pii pair <int,int>
ll mod=1000000007;
ll powr(int x,int y)
{
	if(x==0)
		return 1;
	if(x==1)
		return y;
	ll ans;
	if(x%2==0)
	{
		ll t=powr(x/2,y);
		ans=(t*t)%mod;
	}
	else
	{
		ll t=powr(x/2,y);
		ans=((y*t)%mod *t)%mod;
	}
//	cout<<ans<<nl;
	return ans%mod;

}

int main()
{
	fast;
	int n;cin>>n;
	if(n==1)cout<<0;
	else
	{
		ll ten=powr(n,10);
		ll nine=powr(n,9);
		ll eight=powr(n,8);
		ll ans = (((ten+eight)%mod -(2*nine)%mod)+mod)%mod;
		cout<<ans;
	}

}

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

int main()
{
	std::vector<int> height(10);

	for(int i=0;i<10;++i)
	{
		std::cin >> height[i];
	}

	std::sort(height.begin(),height.end());

	std::cout << height[9] << '\n';

	std::cout << height[8] << '\n';

	std::cout << height[7] << '\n';
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    COMinit();
    long long s;
    cin >> s;
    long long ans = 0;
    for (long long i = 1; i <= s / 3; i++) { //iは項の数
        long long t = s - 3 * i;
        //t+1Hi-1=t+i-1Ci-1
        ans = (ans + COM(t + i - 1, i - 1)) % MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 15504
# 2020/03/22
# AtCoder Beginner Contest 159 - B

# Input
s = input()
l = len(s)
cidx = (l // 2) + 1

kflg = True

for i in range(l):
    if s[i] != s[l-1-i]:
        kflg = False
        break

if kflg == True:
    for x in range(cidx - 2):
        if s[x] != s[cidx-2-x]:
            kflg = False
            break

if kflg == True:
    for y in range(cidx, l):
        if s[y] != s[l-1-(y-cidx)]:
            kflg = False
            break

# Calc
if kflg == True:
    ans = "Yes"
else:
    ans = "No"

# Output
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	if(N%10 == 1 || N%10 == 3 || N%10 == 7 || N%10 == 9){
		int i = 1;
		int k = 7;
		while(i != -1){
			if(k%N == 0){
				cout << i << endl;
				break;
			}else{
				i++;
				k = k%N*10+7;
			}
		}
	}else{
		cout << "-1" << endl;
	}
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,fa[N];

int getfa(int x) {
	return x==fa[x] ? x : fa[x]=getfa(fa[x]);
}

int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++) fa[i]=i;
	for (int i=1;i<=m;i++) {
		int x,y,z; scanf("%d%d%d",&x,&y,&z);
		int fx=getfa(x),fy=getfa(y);
		if (fx!=fy) fa[fy]=fa[fx];
	}
	int ans=0;
	for (int i=1;i<=n;i++) 
		if (fa[i]==i) ans++;
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void ans(ll n){
  if (n == 0) {
    return;
  }
  ans((n - 1) / 26);
  cout << (char)((n - 1) % 26 + 'a');
  return;
}
 
signed main(){
  ll n;
  cin >> n;
  ans(n);
  cout << '\n';
  return 0;
}

Measured memory_bytes: 3612
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1000000 + 5;

int vis[N];

void solve()
{
    string s;
    cin >> s;
    if (s.size() < 26) {
        for(int i = 0; i < (int)s.size(); ++ i) {
            vis[s[i] - 'a'] ++;
        }
        for(int i = 0; i < 26; ++ i) {
            if (!vis[i]) {
                cout << s << char('a' + i) << endl;
                return;
            }
        }
    }
    for(int i = (int)s.size() - 1; i >= 0; --i) {
        int c = s[i] - 'a';
        for(int j = c + 1; j < 26; ++ j) {
            if (vis[j]) {
                cout << s.substr(0, i) << char('a' + j) << endl;
                return;
            }
        }
        vis[c] ++;
    }
    cout << -1 << endl;
}

int main()
{
    solve();
    return 0;
}



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

int main () {
    int N;
    cin >> N;
    vector<int> vec(N);

    for (int i = 0; i < N; i++) {
        vec.at(i) = i + 1;
    }

    double count = 0;

    for (int i = 0; i < N; i++) {
        if (vec.at(i) % 2 == 1) {
            count++;
        }
    }

    double p = count / N;

    printf("%.12f", p) ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
repone(i,x+1){
  std::cin >> y;
  if(y!=i)z++;
}
if(z==0||z==2)std::cout << "YES" << '\n';
else std::cout << "NO" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a.at(i);

    ll x=0, y=0;
    map<ll, ll> mp;
    rep(i, n){
        mp[a.at(i)]++;
    }

    for(auto z: mp){
        if(z.second>=4){
            x = max(x, z.first);
            y = max(y, z.first);
        }
        else if(z.second>=2){
            if(x<z.first){
                y = x;
                x = z.first;
            }
        }
    }

    cout << x * y << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{

    int n;
    
    scanf("%d", &n);
    
    int game[n][3];
    int result[n][3];
    
    int i, j, k;
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < 3; j++) {
            scanf("%d", & game[i][j]);
            result[i][j] = game[i][j];
        }
    }
    
    for (j = 0; j < 3; j++) {
        for (i = 0; i < n; i++) {
            for (k = 0; k < n; k++) {
                if (k != i) {
                    if (game[i][j] == game[k][j]) {
                        result[i][j] = 0;
                    }
                }
            }
        }
    }
    
    for (i = 0; i < n; i++) {
        int sum = 0;
        for (j = 0; j < 3; j++) {
            sum += result[i][j];
        }
        printf("%d\n", sum);
    }
    
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    int m;
    vector<int> x;
    int x_tmp;
    int ans=0;

    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> x_tmp;
        x.push_back(x_tmp);
    }
    sort(x.begin(),x.end());
    vector<int> x_dist(m-1);
    for(int i=0; i<m-1; i++){
        x_dist[i] = x[i+1] - x[i];
    }
    sort(x_dist.begin(),x_dist.end());
    if(n<m){
        for(int i=0; i<m-n; i++){
            ans += x_dist[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1144
N = int(input())
l = ["a"]
alpha = ['a','b','c','d','e','f','g','h','i','j']

alpha = alpha[:N]

counter = 1

def num(s):#文字列sに現れる文字の種類
    counter = 0
    for i in range(len(s)):
        if s[i] not in s[:i]:
            counter += 1
    return counter

while counter != N: 
    l1 = []
    for i in range(len(l)):
        for j in range(num(l[i])+1):
            l1.append(l[i]+alpha[j])
    l = l1[:]
    counter += 1
l.sort()

for k in range(len(l)):
    print(l[k])
        

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

#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    int ans = 0;
    string s, t;

    cin >> s;
    cin >> t;
    REP(i, s.length()) {
        if (s[i] == t[i]) {
            ans++;
        }
    }

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

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

def main():
    A,B = map(int,input().split())
    if A > 0:
        print("Positive")
    elif A == 0:
        print("Zero")
    else:
        if B >= 0:
            print("Zero")
        else:
            n = B-A+1
            if n%2 == 0:
                print("Positive")
            else:
                print("Negative")
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
def judge(bit):
    global l
    for i in range(n):
        if (bit>>i)&1 == 0:
            continue
        for x,y in l[i]:
            if y==1 and (bit>>x)&1==0:
                return False
            if y==0 and (bit>>x)&1==1:
                return False
    return True

n = int(input())
l = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        l[i].append((x-1,y))
maxi = 0
for bit in range(2**n):
    if judge(bit):
        maxi = max(maxi,str(bin(bit)).count('1'))
print(maxi)

Measured memory_bytes: 74436
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0 ; i < n ; i++) cin >> a[i];
    sort(a, a + n);
    int x = 0, y = 0;
    for (int i = n - 1 ; i >= 0 ; i--) {
        if (i % 2 == 0) x += a[i];
        else y += a[i];
    }
    cout << abs(x - y);
}

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

vector<int> edges[100000];

int main(){
    int N, M;
    cin >> N >> M;
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
    }
    int S, T;
    cin >> S >> T;
    S--; T--;

    const int INF = 1e9;
    int dist[100000][3];
    for(int i=0; i<N; i++) for(int k=0; k<3; k++) dist[i][k] = INF;
    dist[S][0] = 0;
    queue<pair<int, int>> que;
    que.push({S, 0});

    while(que.size()){
        auto p = que.front(); que.pop();
        int i = p.first, x = p.second;
        int y = (x+1) % 3;
        for(int j : edges[i]){
            if(dist[j][y] == INF){
                dist[j][y] = dist[i][x] + 1;
                que.push({j, y});
            }
        }
    }

    int ans = dist[T][0] == INF ? -1 : dist[T][0]/3;
    cout << ans << endl;
    return 0;
}


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

ll f(ll x, ll y){
    ll i;
    for(i = x; i <= y; i*=2){
        if(i*2 > y){
            return i;
        }
    }
}

int main(){
    ll ans = 0;
    ll x, y; cin >> x >> y;

    for(ll i = f(x,y); i >= x; i /= 2){
        ans++;
    }

    cout << ans << endl;
}

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

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

a = lmp()
k = int(input())
while k != 0:
    k -= 1
    for i in range(1,3):
        if a[i-1] >= a[i]:
            a[i] *= 2
            break
if a[0] < a[1] < a[2]:
    print("Yes")
else:
    print("No")





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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);

const int MAX_N = 112345;
ll dp[MAX_N][13];

int main2() {
  CLR(dp, 0);
  string s; cin >> s;
  int N = s.size();
  dp[0][0] = 1;
  REP(i, N)
    REP(j, 13) {
      if (s[i] == '?') {
        REP(k, 10)
          (dp[i+1][(j*10 + k) % 13] += dp[i][j]) %= MOD;
      } else {
        int k = s[i] - '0';
        (dp[i+1][(j*10 + k) % 13] += dp[i][j]) %= MOD;
      }
    }

  ll ans = dp[N][5];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 11904
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task5 solver = new Task5();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task5 {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			while (true) {
				int n = sc.nextInt();
				int m = sc.nextInt();
				int p = sc.nextInt();
				if (n == 0 && m == 0 && p == 0) break;
				m--;

				int[] x = sc.nextIntArray(n);

				int total = 0;
				for (int i = 0; i < n; i++) total += x[i];
				total *= (100 - p);

				out.println(x[m] > 0 ? total / x[m] : 0);
			}

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

	}
}




Measured memory_bytes: 24764
import java.util.Scanner;

class Main {
	static int mod = 1000000007;
	private static long[] fact;
	private static long[] inv_fact;

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

		int n = sc.nextInt();

		int[] a = new int[20];
		int[][] x = new int[20][20];
		int[][] y = new int[20][20];

		for (int i = 0; i < n; i++) {

			a[i] = sc.nextInt();

			for (int j = 0; j < a[i]; j++) {

				x[i][j] = sc.nextInt();
				y[i][j] = sc.nextInt();

			}
		}

		int ans = 0;

		// n = 3 なら 1 << n は 8, n = 10 なら 1024
		for (int bit = 1; bit < (1 << n); bit++) {
			boolean flag = true;

			for (int i = 0; i < n; ++i) {
				if ((bit & (1 << i)) == 0) {
					continue;
				}
				for (int j = 0; j < a[i]; j++) {
					// マスクしたい人の場所までシフト
					int shiftedBit = bit >> (x[i][j] - 1);
					// マスク
					int maskedBit = shiftedBit & 1;
					// 1:0 0:1 でなければよいのでXOR演算
					int xorBit = maskedBit ^ y[i][j];
					// xorBit == 1 のとき矛盾
					boolean result = xorBit == 1;
					if (result) {
						// 矛盾していたのでflagをfalseに
						flag = false;
					}
				}

			}
			if (flag)
				ans = Math.max(ans, counter(bit));

		}
		System.out.println(ans);

	}

	// 正直者の人数カウンタ
	static int counter(int x) {
		if (x == 0)
			return 0;
		return counter(x >> 1) + (x & 1);
	}

}

Measured memory_bytes: 22996
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T Read(T)() { return readln.chomp.to!(T); }
T[] Reads(T)() { return readln.split.to!(T[]); }
alias read = Read!(int);
alias reads = Reads!(int);

void main() {
    long w,h,x,y;
    readf("%d %d %d %d\n", &w,&h,&x,&y);
    writefln("%.10f %d", 1.0 * w * h / 2.0, (2*x==w && 2*y==h).to!int);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
    IOS;
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << "\n";
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

/*

グリッド
経路数
剰余

x[i][j] = x[i - 1][j] + x[i][j - 1] % mod


*/

const long mod = 1_000_000_007;

void main(){
	int h = read.to!int;
	int w = read.to!int;
	
	char[][] cells;
	foreach(i; 0 .. h) cells ~= readln.chomp.to!(char[]);
	
	long[] xs;
	foreach(i; 0 .. h){
		foreach(j; 0 .. w){
			if(i == 0){
				if(j == 0) xs ~= 1;
				else xs ~= 0;
			}
			if(cells[i][j] == '#'){
				xs[j] = 0;
			}
			else if(j > 0){
				xs[j] += xs[j - 1];
				xs[j] %= mod;
			}
		}
	}
	
	xs[w - 1].writeln;
	
}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
typedef long long LL;
struct node{
	int day,mo;
	
}p[N];
bool cmp(node a,node b){
	if(a.day !=b.day ) return a.day <b.day ;
	return a.mo >b.mo ;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d%d",&p[i].day,&p[i].mo  );
	}
	sort(p+1,p+1+n,cmp);
	priority_queue<int>que;
	int id=1;
	int ans=0;
	for(int i=1;i<=m;++i){
		while(id<=n&&p[id].day <=i){
			que.push(p[id].mo );
			id++;
		}
		if(!que.empty()){
			ans+=que.top();
			que.pop();
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __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 trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,x,T,nxt,pre=0;
  ll ans=0;
  cin>>n>>T;
  nxt=T-1;
  rep(i,1,n+1)
    {
      cin>>x;
      if(i==1) { pre=0; continue; }
      if(x<=nxt) ans+=x-pre,nxt=x+T-1;
      else ans+=nxt-pre+1,nxt=x+T-1;
      pre=x;
    }
  ans+=nxt-pre+1;
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int x,y,s,num=0,ans=-1,vx[9]={-1,-1,-1,0,0,0,1,1,1},vy[9]={1,0,-1,1,0,-1,1,0,-1};
char t;
vvi field(10,vi(10));

void func(int a,int b){
	for(int i=0;i<9;i++){
		int ca=a+vx[i],cb=b+vy[i];
		if(ca>=0&&ca<10&&cb>=0&&cb<10) field[ca][cb]++;
	}
}

int main(){
	while(cin>>x>>t>>y>>t>>s){
		func(x,y);
		if(s==2) continue;
		if(s==1){
			int dx[4]={-1,-1,1,1},dy[4]={1,-1,1,-1};
			for(int i=0;i<4;i++){
				int cax=x+dx[i],cay=y+dy[i];
				if(cax>=0&&cax<10&&cay>=0&&cay<10) field[cax][cay]--;
			}
		}
		else{
			int dx[4]={-2,0,0,2},dy[4]={0,2,-2,0};
			for(int i=0;i<4;i++){
				int cax=x+dx[i],cay=y+dy[i];
				if(cax>=0&&cax<10&&cay>=0&&cay<10) field[cax][cay]++;
			}
		}
	}
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			if(!field[i][j]) num++;
			ans=max(ans,field[i][j]);
		}
	}
	cout<<num<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 1212
N = int(input())
ex_t, ex_x, ex_y = 0, 0, 0
count = 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-ex_x) + abs(y-ex_y) <= abs(t-ex_t) and t%2 == (x+y)%2:
        count += 1
    ex_t, ex_x, ex_y = t, x, y
print('Yes' if count == N else 'No')

Measured memory_bytes: 9144
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        
        System.out.println(Math.min(A,B) + Math.min(C,D));
    }
}
 

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;cin>>N;
	vector<int> hp(100100);
	rep(i,N)cin>>hp[i];
	int ans = hp[0];
	for(int i = 1; i<N; ++i)ans = __gcd(ans, hp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int A[2000001], B[2000001], C[10000];

int main(){
  int n, k=0, i, j;

  scanf("%d",&n);
  if(n < 0 || 2000000 < n) exit(1);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
    if(A[i] < 0 || 10000 < A[i]) exit(2);
    if(A[i] > k) k=A[i];
  }

  for(i=0; i<=k; i++){
    C[i]=0;
  }

  for(j=0; j<n; j++){
    C[A[j]]++;
  }

  for(i=1; i<=k; i++){
    C[i]=C[i]+C[i-1];
  }

  for(j=n-1; j>=0; j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  }

  for(j=0; j<n; j++){
    printf("%d", B[j]);
    if(j < n-1) printf(" ");
  }
  printf("\n");

  return 0;
}
  



Measured memory_bytes: 17388
import java.io.*;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String line=br.readLine();
        String[] split=line.split(" ",0);
        int tate=Integer.parseInt(split[0]);
        int yoko=Integer.parseInt(split[1]);
        System.out.println((tate*yoko)+" "+(tate*2+yoko*2));
    }
}

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

int main(){
int N, K, d, i, j, A, ans=0; cin >> N >> K; int C[N]={};
for(i=0; i<K; i++){
cin >> d;
for(j=0; j<d; j++){ cin >> A; A--; C[A]=1; }
}
for(i=0; i<N; i++){ if(C[i]==0){ ans++; } }
cout << ans << "\n";
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

int main()
{
    int n, m; cin>>n>>m;
    vector<pair<int, int>> v;
    for(int i=0; i<n; ++i) {
        int a, b; cin>>a>>b;
        v.emplace_back(a, b);
    }
    sort(begin(v), end(v));

    long res=0;
    int k=0;
    priority_queue<int> q;
    for(int i=1; i<=m; ++i) {
        while (k<n and v[k].first<=i) {
            q.push(v[k].second);
            ++k;
        }
        if (q.empty()) continue;
        res+=q.top();
        q.pop();
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1908
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll ans;
  ll a,b,c;
  cin >> a >> b >> c;
  cout << a*b*c/2/max({a,b,c}) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, m;
    cin >> n >> m;
    if(m <= n){
        cout << 0 << endl;
        return 0;
    }
    vector<int> a(m), diff(m - 1);
    in_arr(int, a, m);
    sort(a.begin(), a.end());
    rep(i, m - 1){
        diff[i] = a[i + 1] - a[i];
    }
    sort(diff.begin(), diff.end());
    int ret = 0;
    rep(i, m - n){
        ret += diff[i];
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = std.next();
        }

        Map<String, Long> grouping = IntStream.range(0, n)
                .mapToObj(it -> {
                        String text = s[it];
                    return Arrays.stream(text.split(""))
                            .sorted()
                            .collect(Collectors.joining());
                    }
                )
                .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));

        Iterator<Map.Entry<String, Long>> it = grouping.entrySet().iterator();
        long ans = 0;
        while (it.hasNext()) {
            Map.Entry<String, Long> entry = it.next();
            long count = entry.getValue();
            if (count > 1) {
                ans += count * (count - 1) / 2;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 117432
#include <stdio.h>
     
    int main(void) {
      int n,t,c[200000],i,ans = 0;
      scanf("%d %d",&n,&t);
      for (i = 0;i < n;i++) {
        scanf("%d",&c[i]);
      }
      for (i = 1;i < n;i++) {
        if (c[i] < c[i - 1] + t) {
          ans += c[i] - c[i - 1];
        } else {
          ans += t;
        }
      }
      ans += t;
      printf("%ld\n",ans);
      return 0;
    }

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

using namespace std;

int main()
{
  int n, nx, a, sum;

  scanf("%d", &n);

  nx = n;

  while (true)
  {
    sum += nx % 10;
    nx /= 10;

    if (nx == 0)
      break;
  }

  cout << (n % sum == 0 ? "Yes" : "No");
}

Measured memory_bytes: 256
// Ennichi
import java.util.Scanner;

public class Main {
	private int h, w, n;
	private char[][] field;

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt();
		w = sc.nextInt();
		n = sc.nextInt();
		field = new char[h][w];

		for (int i = 0; i < h; i++)
			field[i] = sc.next().toCharArray();

		boolean win = false;
		out: for (int i = 0; i < h; i++)
			for (int j = 0; j < w - 1; j++) {
				char[][] tfield = new char[h][w];
				boolean[][] bfield = new boolean[h][w];
				change(j, i, tfield);
				fall(tfield);
				while (canVanish(tfield, bfield)) {
					vanish(tfield, bfield);
					fall(tfield);
				}
				if (isBlank(tfield)) {
					win = true;
					break out;
				}
			}
		if (win) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		sc.close();
	}

	private void change(int x, int y, char[][] tfield) {
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				tfield[i][j] = field[i][j];
		char t = tfield[y][x];
		tfield[y][x] = tfield[y][x + 1];
		tfield[y][x + 1] = t;
	}

	private boolean canVanish(char[][] tfield, boolean[][] bfield) {
		if (isBlank(tfield))
			return false;
		boolean ret = false;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++) {
				char c = tfield[i][j];
				if (c == '.')
					continue;
				if (i <= h - n) {
					boolean b = true;
					for (int k = 1; k < n; k++) {
						b = b && tfield[i + k][j] == c;
					}
					if (b) {
						ret = true;
						for (int k = 0; k < n; k++) {
							bfield[i + k][j] = true;
						}
					}
				}
				if (j <= w - n) {
					boolean b = true;
					for (int k = 1; k < n; k++) {
						b = b && tfield[i][j + k] == c;
					}
					if (b) {
						ret = true;
						for (int k = 0; k < n; k++) {
							bfield[i][j + k] = true;
						}
					}
				}
			}
		return ret;
	}

	private void vanish(char[][] tfield, boolean[][] bfield) {
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				if (bfield[i][j]) {
					tfield[i][j] = '.';
					bfield[i][j] = false;
				}
	}

	private void fall(char[][] tfield) {
		for (int j = 0; j < w; j++) {
			int height = h - 1;
			for (int i = h - 1; i >= 0; i--) {
				if (tfield[i][j] != '.') {
					if (i != height) {
						tfield[height][j] = tfield[i][j];
						tfield[i][j] = '.';
					}
					height--;
				}
			}
		}
	}

	private boolean isBlank(char[][] tfield) {
		for (int i = 0; i < w; i++)
			if (tfield[h - 1][i] != '.')
				return false;
		return true;
	}

}

Measured memory_bytes: 27364
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<queue>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define ARRAY_MAX 100005


int main(){

    int n,m;
    cin >> n >> m;
    vector<int> arr(n,1);
    vector<bool> red(n,false);
    red[0] = true;
  
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        if(red[a]){
            //抜き取るほうに赤があるならその次も赤が入る候補
            red[b] = true;
        }
        arr[a]--;//抜いたので減らす
        arr[b]++;//入れたので増やす
        if(arr[a] == 0){
            red[a] = false;
        }
    }
    int ans = 0;
    REP(i,n){
        if(red[i]){
            ans++;
        }
    }
 
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 640
import numpy as np

N,K,Q = map(int,input().split())

S = np.array([ K-Q ] * N)

for i in range(Q):
    # a番目の人が正解
    a = int(input())
    S[a-1] += 1

for j in range(N):
    if S[j] <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 21408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	V<ll> a(n);
	V<ll> b(n);
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i] + i;
	}
	
	ll ans = 0;
	map<ll, int> cnt;

	rep(i, n - 1) {
		cnt[b[i]]++;
		ll k = 2 * (i + 1) - b[i + 1];
		ans += cnt[k];
	}

	cout << ans << endl;

}

Measured memory_bytes: 29008
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    N = read_int()
    S, T = read_str_list()
    res = ''
    for i in range(N):
      res += S[i] + T[i]
    print(res)


main()


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  String s=sc.next();
	  int n=Integer.valueOf(s.substring(s.length()-1, s.length()));
	  if(n==2||n==4||n==5||n==7||n==9) {
		  System.out.println("hon");
	  }else if(n==0||n==1||n==6||n==8) {
		  System.out.println("pon");
	  }else {
		  System.out.println("bon");
	  }
  }
}

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

int main(){
  int n;
  cin>>n;
  int h[105];
  int ma=0;
  rep(i,n){
    cin>>h[i];
    ma=max(h[i],ma);
  }
  int ans=0;
  rep(i,ma){
    bool f=true;
    rep(j,n){
      if(h[j]==0){
	f=true;
	continue;
      }
      h[j]--;
      if(f){
        ans++;
        f=false;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
<?php
$n = ints();
echo lcmAll($n);
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}
//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}
//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}
//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}

Measured memory_bytes: 4604
n = int(input())
a = list(int(i) for i in input().split())

a.sort()
a.reverse()
max = 0

for i in range(1, n):
  m = min(a[0] - a[i], a[i])
  #c = comb(a[0], a[i])
  if m > max:
    max = m
  else:
    i -= 1
    break

if i == 0:
  print(a[0], a[1])
else:
  print(a[0], a[i])


Measured memory_bytes: 14060