akhauriyash/Code-Regression huggingface dataset:
// 横型探索

#include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int w, h;
int mx[] = {0, 0, -1, 1};
int my[] = {-1, 1, 0, 0};

int main() {
    while ( true ) {
        int x, y, cnt = 0;
        cin >> w >> h;
        if ( w == 0 && h == 0 ) break;

        vector<string> v(h);
        queue<int> s;

        for ( int i = 0; i < h; i++ ) {
            cin >> v[i];

            // @の座標を記録
            for ( int j = 0; j < v[i].size(); j++ ) {
                if ( v[i][j] == '@' ) {
                    y = i;
                    x = j;
                }
            }
        }

        // キューにスタート地点を追加
        s.push(x);
        s.push(y);

        while(!s.empty()) {
            x = s.front(); s.pop();
            y = s.front(); s.pop();

            for ( int i = 0; i < 4; i++ ) {
                int nx = x + mx[i], ny = y + my[i];
                if ( 0 <= nx && nx < w && 0 <= ny && ny < h && v[ny][nx] == '.' ) {
                    v[ny][nx] = '#';
                    s.push(nx);
                    s.push(ny);
                }
            }
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  int N,sum=0;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
	cin >> a[i];
	sum+=a[i];
	a[i]*=N;	
  }
  int min=sum*N;
  int min_num=0;
  for(int i=0;i<N;i++){
	if(min>abs(sum-a[i])){
	  min=abs(sum-a[i]);
	  min_num=i;
	}
  }

  cout << min_num << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
/*ll get(ll *arr,ll low,ll high,ll n){
	int mid=low+(high-low)/2;
	if((mid==0 or arr[mid-1]<=arr[mid]) and (mid==(n-1) or arr[mid+1]<=arr[mid])){
		return arr[mid];
	}
	else if(mid>0 and arr[mid-1]>arr[mid]){
		return get(arr,low,mid-1,n);
	}
	else{
		return get(arr,mid+1,high,n);
	}
}*/
/*ll get(int *arr,int n,int left,int i){
	if(i==n){return 1;}
	int curr=arr[i];
	int right=get(arr,n,arr[i]*left,i+1);
	arr[i]=left*right;
	return curr*right;
}*/
/*ll get(int *arr,int n){
	int low=0,high=n-1;
	while(low<=high){
		int mid=low+(high-low)/2;
		int prev=(mid-1+n)%n;
		int next=(mid+1)%n;
		if(arr[mid]<=arr[prev] and arr[mid]<=arr[next]){
			return mid;
		}
		else if(arr[low]<=arr[mid]){
			low=mid+1;
		}
		else if(arr[high]>=arr[mid]){
			high=mid-1;
		}
	}
}*/
/*void get(map<str,int>&m,str s,str ans=""){
	if(s.size()==0){cout<<ans;e;return;}
	for(int i=1;i<=(int)s.size();i++){
		str x=s.substr(0,i);
		if(m[x]){
			get(m,s.substr(i),ans+" "+x);
		}
	}
}*/
void solve(){
	ll d,t,s;cin>>d>>t>>s;
	ll x=t*s;
	if(x>=d){cout<<"Yes";}
	else{cout<<"No";}
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case #"<<k<<": ";
		solve();
		//e;
	}
}


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

int main() {
    int n, a, ans;
    cin >> n;
    ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        if ((i % 2 == 1) & (a % 2 == 1)) {
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef map<ll, ll> mll;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, m, i, a, b, c, s = 0;
	mll vals;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		cin >> a;
		vals[a]++;
	}
	for (i = 0; i < m; i++) {
		cin >> b >> c;
		vals[c] += b;
	}
	c = 0;
	auto it = vals.rbegin();
	while (c < n) {
		i = min(n - c, it->second);
		c += i;
		s += it->first * i;
		it++;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
 
int main(){
	int i;
	int j;
	int h;
	int w;
	char a[101][101];
	scanf("%d%d",&h,&w);
	for(i=0;i<h;i++){
		
		
	
			
			
			scanf("%s",a[i]);
			
			

		

	}
	for(i=0;i<w+2;i++){
		
		printf("#");
		
		
		
	}
	printf("\n");
	for(i=0;i<h;i++){
		
		
		
		printf("#%s#\n",a[i]);
		
		
		
		
		
	}
		for(i=0;i<w+2;i++){
		
		printf("#");
		
		
		
	}
	printf("\n");
return 0;
}

Measured memory_bytes: 128
# Union Find
#0オリジン以下注意

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
def unite(x, y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きい方がx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y] #ここで集合の個数を更新している
        par[y] = x
        return True
    
#xとyが同じ集合に含まれているかどうかを判定(同じ集合にあればTrue)
def same(x, y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size, 子なら親の頂点
################以下にコードを書く

while True:
    w, h = map(int, input().split())
    par = [-1]*(w*h)
    if (w, h) == (0, 0):
        break
    li = []
    for i in range(h):
        li.append(list(map(int, input().split())))
    for i in range(h):
        for j in range(w-1):
            if li[i][j] == li[i][j+1]:
                unite(w*i+j, w*i+j+1)
    for j in range(w):
        for i in range(h-1):
            if li[i][j] == li[i+1][j]:
                unite(w*i+j, w*i+j+w)
    for i in range(h):
        for j in range(w):
            I1 = i+1
            I2 = i-1
            J = j+1
            if 0 <= I1 and I1<h and 0<=J and J<w:
                if li[i][j] == 1 and li[I1][J] == 1:
                    unite(w*i+j, w*I1+J)
            if 0 <= I2 and I2<h and 0<=J and J<w:
                if li[i][j] == 1 and li[I2][J] == 1:
                    unite(w*i+j, w*I2+J)

                    
    #島を数える
    #陸のリスと
    li_riku = []
    for i in range(h):
        for j in range(w):
            if li[i][j]==1:
                li_riku.append(w*i+j)
    li_island = []
    sum_size = len(li_riku)
    for i in li_riku:
        k = find(i)
        if k not in li_island:
            li_island.append(k)
    print(len(li_island))


Measured memory_bytes: 5772
N = int(input())
h = list(map(int, input().split()))
dp = [10**9 for i in range(N+5)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2,N):
    dp[i] = min(dp[i - 1] + abs(h[i-1] - h[i]),dp[i-2] + abs(h[i-2] - h[i]))
print(dp[N-1])

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const ll INF = (ll) 1e18 + 5;

struct edge{
	int to, cost;
	edge(int to, int cost):to(to), cost(cost){}
};

const int MAX_V = 100005;
int n;

vl dijkstra(int s, vector<vector<edge>> & g){
	priority_queue<pi, vector<pi>, greater<pi>> que;
	vl d(n, 1e18);
	d[s] = 0;
	que.push(pi(0, s));
	while(!que.empty()){
		pi p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto &e : g[v]){
			ll cost = e.cost;
			int u = e.to;
			if (d[u] > d[v] + cost){
				d[u] = d[v] + cost;
				que.emplace(d[u], u);
			}
		}
	}

	return d;
}

int main(){
	int m, s, t; cin >> n >> m >> s >> t;
	s--; t--;
	vector<vector<edge>> g0(n), g1(n);
	rep(i,m){
		int u, v, a, b; cin >> u >> v >> a >> b;
		u--; v--;
		g0[u].emplace_back(v, a);
		g0[v].emplace_back(u, a);
		g1[u].emplace_back(v, b);
		g1[v].emplace_back(u, b);
	}
	vl da = dijkstra(s, g0);
	vl db = dijkstra(t, g1);
	vl d(n, 1e15);
	d[n-1] -= da[n-1] + db[n-1];
	for(int i = n-2; i>=0; i--){
		d[i] = max(d[i+1], d[i] - da[i] - db[i]);
	}
	rep(i,n){
		cout << d[i] << endl;
	}
}

Measured memory_bytes: 16184
#include<bits/stdc++.h>
using namespace std;
#define MAXN	3005
#define P	1000000007
int n, m, f[MAXN][MAXN][2];
int update(int &x, int y) {
	return x = (x + y) % P;
}
int main() {
	cin >> n >> m;
	for (int i = 0; i <= n; i++)
		f[0][i][0] = 1;
	for (int i = 0; i < m; i++)
	for (int j = 0, k = n; j <= n; j++, k--) {
		if (j != 0) {
			if (j == 1) {
				update(f[i + 1][j][1], f[i][j][0]);
				update(f[i + 1][j][1], f[i][j][1]);
				update(f[i + 1][j - 1][1], f[i][j][0]);
				update(f[i + 1][j - 1][1], f[i][j][1]);
			} else {
				update(f[i + 1][j][0], f[i][j][0]);
				update(f[i + 1][j][1], f[i][j][1]);
				update(f[i + 1][j - 1][0], f[i][j][0]);
				update(f[i + 1][j - 1][1], f[i][j][1]);
			}
		}
		if (k != 0) {
			if (j == 0) {
				update(f[i + 1][j][1], f[i][j][0]);
				update(f[i + 1][j][1], f[i][j][1]);
				update(f[i + 1][j + 1][1], f[i][j][0]);
				update(f[i + 1][j + 1][1], f[i][j][1]);
			} else {
				update(f[i + 1][j][0], f[i][j][0]);
				update(f[i + 1][j][1], f[i][j][1]);
				update(f[i + 1][j + 1][0], f[i][j][0]);
				update(f[i + 1][j + 1][1], f[i][j][1]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++)
		update(ans, f[m][i][1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n, k;
  int a[220000];
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  int b[220000];
  if(k < 100){
    while(k--){
      rep(i, n){
        int l = max(0, i - a[i]);
        int r = min(n-1, i + a[i])+1;
        b[l]++;
        if(r < n) b[r]--;
      }
      rep(i, n-1){
        b[i+1] += b[i];
      }
      rep(i, n) a[i] = b[i];
      fill(b, b+220000, 0);
    }
  }else{
    fill(a, a+220000, n);
  }

  rep(i, n) cout << a[i]<<" ";
  cout <<endl;
}

Measured memory_bytes: 5156
from collections import deque

n, m = map(int,input().split())
graph = [[] for _ in range(n+1)]

for i in range(m):
    a, b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
    
ans = [0]*(n+1)
seen = [False]*(n+1)

que = deque()
que.append(1)

while len(que) != 0:
    k = que.popleft()
    seen[k] = True
    
    for i in graph[k]:
        if seen[i]:
            continue
        ans[i] = k
        que.append(i)
        seen[i] = True

ans = ans[2:]

for i in ans:
    if i == 0:
        print('No')
        exit()

print('Yes')

for i in ans:
    print(i)

Measured memory_bytes: 35464
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

vector<int> g[N];
int deg[N];
bool seen[N];

bool cycle(int u, int v, int p);

int main() {
	fast_cin();
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		int u, v;
		cin >> u >> v;
		++deg[u]; ++deg[v];
		g[u].pb(v);
		g[v].pb(u);
	}
	bool ok = false;
	vector<int> deg4;
	for (int i = 1; i <= n; ++i) {
		if (deg[i] % 2) {
			cout << "No\n";
			return 0;
		} else if (deg[i] >= 6) {
			ok = true;
		} else if (deg[i] >= 4) {
			deg4.pb(i);
		}
	}
	if (deg4.size() >= 3 or ok) {
		cout << "Yes\n";
	} else if (deg4.size() <= 1) {
		cout << "No\n";
	} else if (cycle(deg4[0], deg4[1], 0)) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

bool cycle(int u, int v, int p) {
	seen[u] = true;
	for (auto &i : g[u]) {
		if (i == v or i == p) {
			continue;
		} else if (seen[i]) {
			return true;
		} else if (cycle(i, v, u)) {
			return true;
		}
	}
	return false;
}

Measured memory_bytes: 7424
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define Max(_A,_B) (_A>_B?_A:_B)
#define Min(_A,_B) (_A<_B?_A:_B)
#define Abs(_A) ((_A)?(_A):(-(_A))
#define INF 0x3f3f3f3f
long long x,y;
void init(){
    scanf("%lld%lld",&x,&y);
    printf("%lld",x+(y>>1));
}
int main(){
	init();
	return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

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

  ll a, b; cin >> a >> b;
  ll g = gcd(a, b);
  cout << a / g * b << endl;
}


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

double dp[305][305][305];

int n;

double rec(int i, int j, int k) {

  if(i < 0 || j < 0 || k < 0) return 0.0;
  if(dp[i][j][k] >= 0.0) return dp[i][j][k];
 
  double res;

  res = rec(i-1,j,k) * i + rec(i+1,j-1,k) * j + rec(i,j+1,k-1) * k + n;

  res *= 1 / (double)(i + j + k);

  return dp[i][j][k] = res;
}


int main() {

  cin >> n;

  int I = 0, J = 0, K = 0;
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if(a == 1) I++;
    else if(a == 2) J++;
    else K++;
  }

  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= n; j++) {
      for(int k = 0; k <= n; k++) {
	dp[i][j][k] = -1;
      }
    }
  }

  dp[0][0][0] = 0;

  cout << fixed << setprecision(10) << rec(I,J,K) << endl;
}
  


Measured memory_bytes: 219392
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  ll K;
  cin >> K;
  rep(i,K){
    cout << "ACL";
  }
  cout << endl;
    
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
    string s;

    cin >> s;
    if (s.substr(2,1) == s.substr(3, 1) and s.substr(4, 1) == s.substr(5, 1)){
        cout << "Yes";
    } else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
def split(word): 
    return [char for char in word]
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
a,b=map(int,input().split())
ans=[]
abin="{0:b}".format(a)
bbin="{0:b}".format(b)
abin=split(abin)
bbin=split(bbin)
abin.reverse()
bbin.reverse()
for i in range(len(bbin)-len(abin)):
  abin.append('0')
if (abin[0]=='1' and ((b-a)%4==0 or (b-a)%4==1)) or (abin[0]=='0' and ((b-a)%4==1 or (b-a)%4==2)) :
  ans.append('1')
else:
  ans.append('0')
for i in range(1,len(bbin)):
  flag=0
  if abin[i]=='1' and a%2==1:
    flag+=1
  if bbin[i]=='1' and b%2==0:
    flag+=1
  if flag==1:
    ans.append('1')
  else:
    ans.append('0')
ans.reverse()
print(int(convert(ans),2))

Measured memory_bytes: 3064
#include <algorithm>
#include <string.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long int ll;
const int N = 3e5 + 10;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (c % max(a, b) == 0)
        cout << c / (max(a, b)) << endl;
    else
        cout << c / (max(a, b)) + 1 << endl;

    return 0;
}


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

int main()
{
  int A, B, count = 0;
  cin >> A >> B;
  for (int i = A; i <= B; i++)
  {
    int first, second, fourth, fifth;
    first = i / 10000;
    second = (i / 1000) % 10;
    fourth = (i % 100) / 10;
    fifth = i % 10;

    if (first == fifth && second == fourth)
    {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if (x-r >= 0 && y-r >= 0 && x+r <= w  && y+r <= h)
       cout << "Yes" << endl;
    else
       cout << "No" << endl;
    
}


Measured memory_bytes: 3116
#include<stdio.h>
#include<math.h>
 
struct Point { double x,y;};
 
void koch(int n, Point a,Point b){
    if(n==0)return;
     
    Point s,t,u;
    double th=M_PI*60.0/180.0;
     
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
     
    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}
 
int main(){
    Point a,b;
    int n;
    scanf("%d",&n);
     
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
     
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
     
    return 0;
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
  
using namespace std;
  
#define MAX 201
typedef pair<string,string> P;
 
int N,D,idx;
string s[MAX];
map<int,set<string> > mp;
vector<P> vec;
 
void dfs(string now,int step){
    if(step == 1){
	mp[idx].insert(now);
	return;
    }
   
    int len = now.size();
    // delete
    for(int i = 0 ; i < len ; i++){
	string tmp = now;
	tmp.erase(tmp.begin()+i);
	dfs(tmp,step+1);
    }
  
    // swap
    for(int i = 0 ; i < len-1 ; i++){
	swap(now[i],now[i+1]);
	dfs(now,step+1);
	swap(now[i],now[i+1]);
    }
 
    // insert
    for(char ch = 'a' ; ch <= 'z' ; ch++){
	for(int j = 0 ; j < len+1 ; j++){
	    string tmp = now;
	    tmp = tmp.substr(0,j) + ch + tmp.substr(j);
	    dfs(tmp,step+1);
	}
    }
  
    // replace
    for(char ch = 'a' ; ch <= 'z' ; ch++){
	for(int j = 0 ; j < len ; j++){
	    char c = now[j];
	    now[j] = ch;
	    dfs(now,step+1);
	    now[j] = c;
	}
    }
}
 
void init(){
    mp.clear();
    vec.clear();
}
 
int main(){
    while(cin >> N, N){
	cin >> D;
	init();
	for(int i = 0 ; i < N ; i++){
	    cin >> s[i];
	}
	for(int i = 0 ; i < N ; i++){
	    idx = i;
	    dfs(s[i],0);
	}
 
	vector<string> v[MAX];
	for(int i = 0 ; i < N ; i++){
	    set<string> st = mp[i];
	    set<string>::iterator it;
	    for(it = st.begin() ; it != st.end() ; ++it){
		v[i].push_back(*it);
	    }
	} 
 
	if(D == 1){
	    for(int i = 0 ; i < N ; i++){
		unordered_map<string,bool> ump;
		for(int j = 0 ; j < (int)v[i].size() ; j++){
		    ump[v[i][j]] = true;
		}
		for(int j = i+1 ; j < N ; j++){
		    if(ump.find(s[j]) != ump.end()){
			vec.push_back(P(s[i],s[j]));
		    }
		}
	    }
	}else{
	    for(int i = 0 ; i < N ; i++){
		unordered_map<string,bool> ump;
		for(int j = 0 ; j < (int)v[i].size() ; j++){
		    ump[v[i][j]] = true;
		}
		for(int j = i+1 ; j < N ; j++){
		    for(int k = 0 ; k < (int)v[j].size() ; k++){
			if(ump.find(v[j][k]) != ump.end()){
			    vec.push_back(P(s[i],s[j]));
			    break;
			}
		    }
		}
	    }
	}
	int len = vec.size();
	for(int i = 0 ; i < len ; i++){
	    if(vec[i].first > vec[i].second){
		swap(vec[i].first,vec[i].second);
	    }
	}
	sort(vec.begin(),vec.end());
	for(int i = 0 ; i < len ; i++){
	    cout << vec[i].first << "," << vec[i].second << endl;
	}
	cout << len << endl;
    }
    return 0;
}

Measured memory_bytes: 19360
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n ; cin >> n;
    cout << 0 << endl;
    pair<ll,bool> left,right,center;
    string s; cin >> s;
    if(s.at(0)=='V'){ return 0;}
    else if(s.at(0)=='M'){left = make_pair(0,0),right = make_pair(n,0);}
    else if(s.at(0)=='F'){left = make_pair(0,1),right = make_pair(n,1);}
    while(true){
        center.first = (left.first+right.first)/2;
        cout << center.first << endl;
        cin >> s;
        char sex = s.at(0);
        if(sex=='V'){
            return 0;
        }else{
            center.second = (sex=='F');
            if(left.first%2 == center.first%2){
                if(left.second==center.second){
                    left = center;
                }else{
                    right = center;
                }                
            }else{
                if(left.second==center.second){
                    right = center;
                }else{
                    left = center;
                }                
            }            
        }
    }
    return 0;
}

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

int main() {
  int N, b;
  cin >> N;
  b = 0;
  for(int i = 1; i < 10; i++) {
    for(int j = 1; j < 10; j++) {
      if(N == i * j) b++;
    }
  }
  if(b == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>

using namespace std;

const int MAXI = 1e5;

template <class T>
vector<bool> get_is_prime(T n) {
	vector<bool> p(n + 1, true);
	p[0] = p[1] = false;

	T limit = sqrt(n);
	for (T i = 4; i <= n; i += 2) {
		p[i] = false;
	}
	for (T i = 3; i <= limit; i += 2) {
		if (p[i]) {
			for (T j = i * i; j <= n; j += i) {
				p[j] = false;
			}
		}
	}

	return p;
}

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

	auto is_primes = get_is_prime(MAXI);
	auto like2017 = is_primes;
	like2017[2] = false;
	for (int i = 3; i < like2017.size(); i += 2) {
		if (!like2017[i]) {
			continue;
		}
		int x = i;

		if (!is_primes[(i + 1) / 2]) {
			like2017[i] = false;
		}
	}

	vector<int> cumuls(like2017.size() + 1, 0);
	for (int i = 1; i < cumuls.size(); i++) {
		cumuls[i] = cumuls[i - 1] + like2017[i - 1];
	}

	int q, l, r;
	cin >> q;
	vector<int> ans(q, 0);
	for (int i = 0; i < q; i++) {
		cin >> l >> r;
		ans[i] = cumuls[r + 1] - cumuls[l];
	}


	for (auto x : ans) {
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;


int main(){
    int N, M;
    string b;
    cin>>N;
    vector<string> a(N);
    map<string, int> s; 
    for(int i=0;i<N;i++){
        cin>>a[i];
        s[a[i]]++;
    }
    cin>>M;
    for(int i=0;i<M;i++){
        cin>>b;
        s[b]--;
    }
    int m = 0;
    for(int i=0;i<N;i++){
        m=max(m, s[a[i]]);
    }
    cout << m <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	priority_queue<pair<long long,long long> > pq;
	
	for(int i=0;i<n;++i){
		long long t,d;
		cin >> t >> d;
		pq.push(pair<long long,long long>(d,t));
	}
	
	
	//cout << "--input--" <<endl;
	priority_queue<long long,vector<long long>,greater<long long> > over;
	
	map<long long,long long> ma;
	long long sum = 0;
	for(int i=0;i<k;++i){
		pair<long long,long long> tmp = pq.top();pq.pop();
		long long d = tmp.first;long long t = tmp.second;
		sum += d;
		if(ma.find(t) == ma.end()) ma.insert(pair<long long,long long>(t,1));
		else ma[t]++;
		if(ma[t] > 1) over.push(d);
		//cout << d << " " << t <<endl;
	}
	long long ans = sum + (long long)ma.size()*(long long)ma.size();
	/*
	cout << sum << " " << ans <<endl;
	cout << ma.size() <<endl;
	cout << "---" <<endl;
	cout << over.size() <<endl;
	*/
	for(int i=k;i<n && !over.empty();++i){
		pair<long long,long long> tmp = pq.top();pq.pop();
		long long d = tmp.first;long long t = tmp.second;
		
		if(ma.find(t) == ma.end()) ma.insert(pair<long long,long long>(t,1));
		else ma[t]++;
		//cout << "-"<<endl;
		if(ma[t] > 1) continue;
		long long e = over.top();over.pop();
		sum -= e;
		sum += d;
		ans = max(ans, sum + (long long)ma.size()*(long long)ma.size());
		//cout << e << " " <<d <<" "<<  t << " " <<  sum<<" "<< ans <<endl;;
	}
	
	cout << ans <<endl;
	
	
	return 0;
}



Measured memory_bytes: 6128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n, k;
    cin >> n >> k;

    cout << (n % k == 0 ? 0 : 1) << endl;

    return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	vector<pair<pair<string, int>, int>> p(n);
	for (int i = 0; i < n; i++) {
		string s;
		int num;
		cin >> s >> num;
		p[i] =  make_pair(make_pair(s, -num), i + 1);
	}
	sort(p.begin(),p.end());
	for (int i = 0; i < n; i++) {
		cout << p.at(i).second << endl;
	}
}

Measured memory_bytes: 3608
#include<stdio.h>

int
main()
{
  	int H,W,h,w;
  	int answer;
  	scanf("%d %d",&H,&W);
  	scanf("%d %d",&h,&w);
  	answer=H*W-H*w-h*W+h*w;
  	printf("%d\n",answer);
  
  	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int tc;
    cin>>tc;
    int f=0;
    while(tc--)
    {
    int n,b,c;
    cin>>n>>b>>c;
    int d=b+c;
    if(n<d)
    {
        f=1;
    }
    else
    {
        if((d%2==0)&&(n%2!=0))
        {
            f=1;
        }
        else if((d%2!=0)&&(n%2==0))
        {
            f=1;

        }
    }

    }
     if(f==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep (i, n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end(), greater<int>());

  int ans = 0;
  rep (i, n) {
    if (i % 2 == 0) ans += v[i];
    else ans -= v[i];
  }
  P(ans);

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int i,j,k,s,n,flag;
    while(scanf("%d%d",&n,&s)!=EOF)
    {
        flag=0;
        for(i=0;i<=n;i++)
        {
        for(j=0;j+i<=n;j++)
        {
            k=i*10000+j*5000+(n-i-j)*1000;
            if(k==s)
            {
                flag=1;
                break;
            }
        }
        if(flag)
            break;
        }
        if(flag)
        printf("%d %d %d\n",i,j,n-i-j);
        else
        printf("-1 -1 -1\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a,b,c,d,n;
int main()
{
	a=getchar()-'0',b=getchar()-'0',c=getchar()-'0',d=getchar()-'0';
	if(a+b+c+d==7) printf("%d+%d+%d+%d=7",a,b,c,d);
	else if(a+b+c-d==7) printf("%d+%d+%d-%d=7",a,b,c,d);
	else if(a+b-c+d==7) printf("%d+%d-%d+%d=7",a,b,c,d);
	else if(a+b-c-d==7) printf("%d+%d-%d-%d=7",a,b,c,d);
	else if(a-b+c+d==7) printf("%d-%d+%d+%d=7",a,b,c,d);
	else if(a-b+c-d==7) printf("%d-%d+%d-%d=7",a,b,c,d);
	else if(a-b-c+d==7) printf("%d-%d-%d+%d=7",a,b,c,d);
	else if(a-b-c-d==7) printf("%d-%d-%d-%d=7",a,b,c,d);
	return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

S = [0,0,0]
for i in range(3):
    S[i] = str(input())

a,b,c = 0,0,0
next = "a"

def check(a,b,c,next):
    if next == "a":

        try:
            next = S[0][a]
            a += 1
        except:
            return 0,0,0,0,"A"
    elif next == "b":

        try:
            next = S[1][b]
            b += 1
        except:
            return 0,0,0,0,"B"
    else:
        try:
            next = S[2][c]
            c += 1
        except:
            return 0,0,0,0,"C"
    return a,b,c,next,0

while True:
    a,b,c,next,ans = check(a,b,c,next)
    if ans != 0:
        break
print(ans)


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

int main() {
  string s;
  cin >> s;
  
  vector<char> S(s.size());
    for (int i = 0; i < s.size(); i++) {
      S.at(i) = s.at(i);
    }
  int count = 0;
  
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < s.size(); j++) {
      if (S.at(i) == S.at(j)){
        count++;
      }
    }
  }
  if (count == s.size()){
    cout << "yes" << endl;
  }
  else {
    cout << "no" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

class MaxFlow {
public:
  struct edge { int to, cap, rev; };

  const int INF = 1 << 28;
  int N;
  vector<vector<edge>> E;
  vector<int> level;
  vector<int> iter;

  MaxFlow(int N): N(N), E(N), level(N), iter(N) {}

  void add_directed_edge(int from, int to, int cap) {
    E[from].push_back((edge) { to, cap, (int) E[to].size() });
    E[to].push_back((edge) { from, 0, (int) E[from].size() - 1 });
  }

  void add_undirected_edge(int from, int to, int cap) {
    E[from].push_back((edge) { to, cap, (int) E[to].size() });
    E[to].push_back((edge) { from, cap, (int) E[from].size() - 1 });
  }

  void bfs(int s) {
    for (int i = 0; i < N; i++) level[i] = -1;
    level[s] = 0;

    queue<int> q;
    q.push(s);

    while (!q.empty()) {
      int v = q.front();
      q.pop();

      for (int i = 0; i < E[v].size(); i++) {
        edge &e = E[v][i];
        if (e.cap > 0 && level[e.to] < 0) {
          level[e.to] = level[v] + 1;
          q.push(e.to);
        }
      }
    }
  }

  int dfs(int v, int t, int f) {
    if (v == t) return f;
    for (int &i = iter[v]; i < E[v].size(); i++) {
      edge &e = E[v][i];
      if (e.cap > 0 && level[v] < level[e.to]) {
        int d = dfs(e.to, t, min(f, e.cap));
        if (d > 0) {
          e.cap -= d;
          E[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  int max_flow(int s, int t) {
    int flow = 0;
    while (1) {
      bfs(s);
      if (level[t] < 0) break;
      for (int i = 0; i < N; i++) iter[i] = 0;
      while (1) {
        int f = dfs(s, t, INF);
        if (f == 0 || f == INF) break;
        flow += f;
      }
    }
    return flow;
  }
};

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<ll> A(M), B(M);
  REP(i, 0, M) cin >> A[i] >> B[i], A[i]--, B[i]--;

  vector<ll> cnt(N);
  REP(i, 0, M) {
    cnt[A[i]]++;
    cnt[B[i]]++;
  }

  bool ok = true;
  REP(i, 0, N) {
    ok = ok && cnt[i] % 2 == 0;
  }
  if (!ok) {
    // cerr << "none loop" << endl;
    cout << "No" << endl;
    return 0;
  }

  vector<ll> x, y;
  REP(i, 0, N) {
    if (cnt[i] >= 6) x.push_back(i);
    if (cnt[i] == 4) y.push_back(i);
  }

  if (x.size() >= 1) {
    // cerr << "x >= 1" << endl;
    cout << "Yes" << endl;
    return 0;
  }
  if (y.size() >= 3) {
    // cerr << "y >= 3" << endl;
    cout << "Yes" << endl;
    return 0;
  }
  if (y.size() <= 1) {
    // cerr << "y <= 1" << endl;
    cout << "No" << endl;
    return 0;
  }

  ll s = y[0], t = y[1];
  MaxFlow mf(N);
  REP(i, 0, M) {
    mf.add_undirected_edge(A[i], B[i], 1);
  }
  ll f = mf.max_flow(s, t);
  if (f == 2) {
    // cerr << "flow = 2" << endl;
    cout << "Yes" << endl;
  } else {
    // cerr << "flow = 4" << endl;
    cout << "No" << endl;
  }
}

Measured memory_bytes: 9856
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		long mod=1000000007;
		char[][] map=new char[h][w];
		for(int i=0; i<h; i++){
			map[i]=sc.next().toCharArray();
		}
		long[][] dp=new long[h+1][w+1];
		dp[1][1]=1;
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				if(map[i-1][j-1]=='.'){
					dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%mod;
				}
			}
		}
		System.out.println(dp[h][w]);
	}
}


Measured memory_bytes: 49504
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for(int i = 0;i < n;i++){
            a.add(sc.nextInt());
        }

        int max = 0;
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                int x = a.get(i) - a.get(j);
                max = Math.max(max,x);
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 21844
N, M = map(int, input().split())
# N, M = 100000, 100000
# N, M = 2, 3

mod = 10 ** 9 + 7
if abs(N - M) >= 2:
    print(0)
else:
    if N == M:
        prod = 1
        for i in range(2, N + 1):
            prod = (prod * i) % mod
        print((prod * prod * 2) % mod)
    else:
        if N < M:
            N, M = M, N
        prod = 1
        ans = 1
        for i in range(2, N + 1):
            prod = (prod * i) % mod
            if i == M:
                ans = (ans * prod) % mod
        print((ans * prod) % mod)


Measured memory_bytes: 3064
while True:
    try:
        Size = []
        Card_Lis = list(map(int,input().split(",")))
        Card_Lis.sort()
        
        
        for tag in sorted(set(Card_Lis), key=Card_Lis.index):
            Size.append(Card_Lis.count(tag))
       
        Size.sort()

        if max(Size) == 4:
            print("four card")
        elif Size == [2,3]:
            print("full house")
        elif max(Size) == 3:
            print("three card")
        elif Size == [1,2,2]:
            print("two pair")
        elif max(Size) == 2:
            print("one pair")
        elif max(Size) == 1:
            if Card_Lis[0] == 1:
                if Card_Lis == [1,2,3,4,5] or Card_Lis == [1,10,11,12,13]:
                    print("straight")
                else:
                    print("null")
            elif Card_Lis[0] + 4 == Card_Lis[4]:
                    print("straight")
            else:
                print("null")
            
    except EOFError:
        break

Measured memory_bytes: 7492
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int A[101010], B[101010];
vector<int> to[101010];

void DFSA(int q, int p){
  for(int k: to[q]){
    if(k==p) continue;
    A[k] = A[q]+1;
    DFSA(k, q);
  }
}

void DFSB(int q, int p){
  for(int k: to[q]){
    if(k==p) continue;
    B[k] = B[q]+1;
    DFSB(k, q);
  }
}

int main(){
  int n, u, v; cin >> n >> u >> v; u--; v--;
  rep(i, n-1){
    int a, b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a);
  }
  DFSA(u, -1);
  DFSB(v, -1);
  int ma = 0;
  rep(i, n){
    if(A[i]<B[i] && ma<B[i]-1 && to[i].size()==1){
      ma=B[i]-1;
    }
  }
  cout << ma << endl;
}

Measured memory_bytes: 14924
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
c = Counter(s)
for key in c.keys():
    if c[key] % 2:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 38384
#include <cstdio>
#include <algorithm>

int main(){
    bool check = true;
    int h, k;
    scanf("%d %d", &h, &k);
    int M[h+2][k+2];
    for(int i=0;i<h+2;i++){
        for(int j=0;j<k+2;j++){
            M[i][j] = '.';
            //printf("%c", M[i][j]);
        }
        //printf("\n");
    }
    //ダミー変数に改行を読み込ませてscanfの誤動作を回避
    char dummy;
    for(int i=1;i<h+1;i++){
        scanf("%c", &dummy);
        for(int j=1;j<k+1;j++){
            scanf("%c", &M[i][j]);
        }
        
    }
    for(int i=1;i<h+1;i++){
        for(int j=1;j<k+1;j++){
            if(M[i][j] == '#'){
                if(M[i][j-1] != '#' && M[i][j+1] != '#' && M[i-1][j] != '#' && M[i+1][j] != '#'){
                check = false;
                }
            }
        }
    }
    /*
    for(int i=1;i<h+1;i++){
        for(int j=1;j<k+1;j++){
            printf("%c", M[i][j]);
        }
        printf("\n");
    }
    */
    if(check){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
    
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int X;
	cin >> X;
	if(X == 3 || X == 5 || X == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

const int DIM = 1e6 + 5;
const int MOD = 1e9 + 7;

int dp[DIM], psm[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    dp[1] = psm[1] = n;
    dp[2] = ( 1LL * n * n ) % MOD;
    psm[2] = ( psm[1] + dp[2] ) % MOD;
    
    for( int i = 3; i <= n; i ++ ) {
        dp[i] = ( 1LL * (n - 1) * (n - 1) % MOD + psm[i - 3] + dp[i - 1] + (n - i + 2) ) % MOD;
        psm[i] = ( psm[i - 1] + dp[i] ) % MOD;
    }
    
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <tuple>
#include <string>

using namespace std;

const int p[9] = {0, 1, 2, 0, -1, 2, 0, 1, 2};

bool solve() {
    string S;
    cin >> S;
    if (S == "#") return false;

    int L = 0, R = 0;
    // 直前が(L, R)だったときの最小コスト
    int pre = p[S[0] - '1'];
    for (int i = 1; i < S.size(); ++i) {
        int nxt = p[S[i] - '1'];
        if (nxt < pre) {
            L = min(L + 1, R);
            R = R + 1;
        } else if (nxt > pre) {
            R = min(L, R + 1);
            L = L + 1;
        } else {
            tie(L, R) = make_pair(min(L + 1, R), min(L, R + 1));
        }
        pre = nxt;
    }

    cout << min(L, R) << endl;
    return true;
}

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



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

int main(void) {

	unsigned long A, B, K, tmp;

	scanf("%lu%lu", &A, &B);

	//Aを大きい値に設定
	if(B > A){
		tmp = A;
		A = B;
		B = tmp;
	}

	if((A-B)%2 != 0){
		printf("IMPOSSIBLE");
	}else{
		K =(A - (A -B)/2) ;
		printf("%lu", K);
	}


	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int ab[26],dep[26],sum;
string s;
struct node{
	int key;
	vector<char>ch;
	friend bool operator<(const node &a,const node &b){return a.key>b.key;}
};
priority_queue<node>pq;
void build(){
	for(int i=0;i<26;i++){
		if(ab[i]!=0){
			node t;
			t.ch.push_back(i);
			t.key=ab[i];
			pq.push(t);
		}
	}
	if(pq.size()==1){
		node a=pq.top();
		dep[a.ch[0]]++;
		return;
	}
	while(pq.size()>1){
		node a=pq.top();pq.pop();
		node b=pq.top();pq.pop();
		for(int i=0;i<b.ch.size();i++)a.ch.push_back(b.ch[i]);
		for(int i=0;i<a.ch.size();i++)dep[a.ch[i]]++;
		a.key+=b.key;
		pq.push(a);
	}
}
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++)ab[s[i]%'a']++;
	build();
	for(int i=0;i<26;i++)sum+=dep[i]*ab[i];
	printf("%d\n",sum);
}



Measured memory_bytes: 3488
#include <stdio.h>
int main(void){
   int i,j;
   int h[11];
   
   for(i=1;i<=10;i++){
       scanf("%d",&h[i]);
   }
   for(i=9;i>=7;i--){
       for(j=1;j<=i;j++){
           if(h[j]>h[j+1]){
               h[0]=h[j+1];
               h[j+1]=h[j];
               h[j]=h[0];
           }
       }
   }
   
  printf("%d\n",h[10]);
  printf("%d\n",h[9]); 
  printf("%d\n",h[8]);
  
   return 0;
}



Measured memory_bytes: 2104
# -*- coding: utf-8 -*-
 
N = int(input())
A = list(map(int,input().split()))

A_sum = sum(A)

ans = 0
for i in range(N-1):
  A_sum -= A[i]
  ans += ( A[i] * A_sum )% (10**9 +7)

ans = ans % (10**9 +7)
print(ans)

Measured memory_bytes: 31488
/**
 * Boris Sokolov
 * Software Engineer at Ring Ukraine
 * Kiev, Ukraine | Los Angeles, CA
 */

// #pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cassert>
#include <chrono>
#include <bitset>
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <cmath>
#include <set>
#include <sstream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstring>
#include <ctime>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

 using namespace std;
// using black magic;

typedef long long ll;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = static_cast<int>(2e9);
const int MOD = static_cast<int>(1e9) + 7;



int main() {
    ll l, r;
    scanf("%lld %lld", &l, &r);

    int res = 0;
    while (l <= r) {
        ++res;
        l <<= 1;
    }

    printf("%d\n", res);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int x, y;
  cin >> x >> y;
  int l, r;
  if((2*x-y)%3==0) {
    l = (2*x-y)/3;
    r = x - 2*l;
    combination C(l+r);
    cout << C(l+r, r).x << endl;
  }
  else cout << 0 << endl;
}


Measured memory_bytes: 10624