akhauriyash/Code-Regression huggingface dataset:
using System;

class Program
{
	static void Main(string[] args)
	{
		int i, j;

		string[] strInput = Console.ReadLine().Split(' ');
		int n = int.Parse(strInput[0]);
		int k = int.Parse(strInput[1]);

		int[] a = new int[n];

		for (i = 0; i < k; i++)
		{
			int d = int.Parse(Console.ReadLine());
			strInput = Console.ReadLine().Split(' ');
			for (j = 0; j < d; j++)
			{
				a[int.Parse(strInput[j]) - 1] = 1;
			}
		}

		int result = 0;
		for(i = 0; i < n; i++)
		{
			if(a[i] == 0)
			{
				result++;
			}
		}

		Console.WriteLine(result);

		return;
	}
}

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

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


void solve5c(int a, int b) {
    REP(i,a) {
        REP(j,b) {
            if (i%2==0) {
                if (j%2==0) {
                    cout << "#";
                }else {
                    cout << ".";
                }
            }else {
                if (j%2==0) {
                    cout << ".";
                }else {
                    cout << "#";
                }
            }
        }
        cout << endl;
    }
    cout << endl;
}

int main() {
    int a, b;
    while(cin >> a >> b, a+b) {
        solve5c(a, b);
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 998244353;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

int mat[301][301];

void xori(int k, int i) {
  if (k==i) return;
  for(int j=0; j<=300; j++) {
    mat[k][j] ^= mat[i][j];
  }
}

void xorj(int k, int j) {
  if (k==j) return;
  for(int i=0; i<=300; i++) {
    mat[i][k] ^= mat[i][j];
  }
}

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

  int n, m; cin >> n >> m;
  
  rep(i, n) {
    rep(j, m) {
      cin >> mat[i][j];
    }
  }

  int maxk = min(n, m);
  int rank = 0;
  rep(k, maxk) {
    int pi, pj; bool find = false;
    for(int i=k; i<n; i++) {
      for(int j=k; j<m; j++) {
        if (mat[i][j]) {
          //debug(i);debugln(j);
          pi = i;
          pj = j;
          find = true;
          break;
        }
      }
      if (find) break;
    }
    if (!find) {
      // calc rank
      break;
    }
    rank++;
    //debug(k);debug(pi);debugln(pj);
    xori(k, pi);
    xorj(k, pj);
    for(int i=k+1; i<n; i++) {
      if (mat[i][k]) {
        xori(i, k);
      }
    }
  }
  //debugln(rank);
  int c = n+m-1;
  int d = n+m-rank-1;

  int ansc = 1;
  int ansd = 1;
  while(c--) {
    ansc <<= 1;
    ansc %= mod;
  }
  while(d--) {
    ansd <<= 1;
    ansd %= mod;
  }
  cout << (ansc+mod-ansd)%mod << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
  int n,ans=0,i;
  char s[60];
  scanf("%d%s",&n,s);
  for(i=0;s[i]!='\0';i++)
    
  if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C'))
    ans++;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import re
n = input()
n1 = input()
m = re.search('(\d+)\s(\d+)', n)
m1 = re.search('(\d+)\s(\d+)', n1)
a = int(m.group(1))
b = int(m.group(2))
c = int(m1.group(1))
d = int(m1.group(2))
ab = a * b
cd = c * b + d * (a - c)
print(ab - cd)


Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args)
    {
        CP sc =new CP();
        String[] s = sc.nextLine().split(" ");
        StringBuilder sb = new StringBuilder();
        for(String x : s){
            if(x.charAt(x.length()-1)=='s')
                x = x + "es";
            else
                x = x + "s";
            if(s.length==1)
                sb.append(x);
            else
                sb.append(x).append(" ");
        }
        System.out.println(sb.toString());
    }
    /*****************************************************************************/
    static class CP
    {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;
        public CP() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }
        int nextInt() {
            return Integer.parseInt(NNNN());
        }
        long nextLong() {
            return Long.parseLong(NNNN());
        }
        double nextDouble() {
            return Double.parseDouble(NNNN());
        }
        String NNNN() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                }
                catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }
        String nextLine() {
            String spl = "";
            try {
                spl = bufferedReader.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return spl;
        }
    }
    /*****************************************************************************/
}

Measured memory_bytes: 36548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);
constexpr int n_max = 2e5+1;
int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i,n) cin >> a[i+1];
  vector<int> res, cnt(n_max, 0);
  for (int i = n; i > 0; i--) {
    int now = 0;
    for (int j = i * 2; j <= n; j += i) now ^= cnt[j];
    cnt[i] = now ^ a[i];
    if (cnt[i]) res.emplace_back(i);
  }
  cout << res.size() << endl;
  for (auto e : res) cout << e << " ";
  cout << endl;
  return 0;
} 

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

int main() {
  string s;
  cin >> s;
  int s_len = s.size();

  int length = 0;
  for(int i=0;i<s_len;i++) {
    if(s[i] == 'A') {
      length -= i-1;
      break;
    }
  }

  for(int i=s_len-1;i>=0;i--) {
    if(s[i] == 'Z') {
      length += i;
      break;
    }
  }
  cout << length << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int n = int.Parse(s);

            int h = n / 3600;
            int m = (n - h * 3600) / 60;
            int s2 = n % 60;


            Console.WriteLine(h+":"+m+":"+s2);
            


            //int tate = int.Parse(s[0]);
            //int yoko = int.Parse(s[1]);

            //int area = tate * yoko;
            //int rect = (tate + yoko )* 2;

            //Console.WriteLine(area + " "+rect);
        }
    }
}

Measured memory_bytes: 5612
using System;

class Plogram
{
    static void Main()
    {

        var n = Console.ReadLine().Split();
        int N = int.Parse(n[0]);
        int M = int.Parse(n[1]);

        int Lmax = 0;
        int Rmin = int.MaxValue;

        for (int i = 0; i < M; i++)
        {
            var num = Console.ReadLine().Split();
            int L = int.Parse(num[0]);
            int R = int.Parse(num[1]);

            if(Lmax < L)
            {
                Lmax = L;
            }
            if(Rmin > R)
            {
                Rmin = R;
            }
        }
        Console.WriteLine(Math.Max(Rmin - (Lmax - 1), 0));
    }
}

Measured memory_bytes: 15296
#include <iostream>
#include <map>
#include <utility>

using namespace std;
int main(){
    long long i,j,k,h,w,n,a,b,c[10],sum=0;
    pair<long long,long long> p;
    map <pair<long long, long long>,int> mp;
    cin >> h  >> w >> n;
    for(i=0;i<10;i++){
        c[i] = 0;
    }
    c[0] = (h-2)*(w-2);
    for(i=0;i<n;i++){
        cin >> a >> b;
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                if(a-k>0 && b-j>0 && a-k+1<h && b-j+1<w){
                    p = make_pair(a-k,b-j);
                    c[mp[p]]--;
                    mp[p]++;
                    c[mp[p]]++;
                }
            }
        }
    }
    for(i=0;i<10;i++){
        cout << c[i] << endl;
    }
}

Measured memory_bytes: 56448
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main() {
	ll n, x0;
	cin >> n >> x0;
	vl d(n);
	rep(i, n) {
		cin >> d[i];
	}
	int q;
	cin >> q;
	vi idx(q);
	rep(i, q) {
		cin >> idx[i];
	}
	vl x(n + 1);
	x[0] = x0;
	rep(i, n) {
		x[i + 1] = min(x[i], abs(x[i] - d[i]));
	}
	vl ng(n);
	ng[n - 1] = 1;
	for (int i = n - 2; i >= 0; i--) {
		if (d[i + 1] / 2 < ng[i + 1]) {
			ng[i] = d[i + 1] + ng[i + 1];
		}
		else {
			ng[i] = ng[i + 1];
		}
	}
	//DEBUG_VEC(ng);
	rep(i, q) {
		int j = idx[i] - 1;
		if (ng[j] <= x[j]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 15616
#include <iostream>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
	ll k;
	cin >> k;
	
	ll sum = 0;
	for(ll a = 1; a <= k; a++) 
		for(ll b = 1; b <= k; b++) 
			for(ll c = 1; c <= k; c++) 	
				sum += __gcd(a, __gcd(b, c));	
				
	cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  vi a(n+1);
  rep2(i,1,n+1) cin >> a[i];
  vi b(n+5,0);
  for(int i = n;i>0;i--){
    int p = i;
    
    int kaisum = 0;
    for(int j = p;j<=n;j+=p){
      b[i] += b[j];
    }
    b[i]%=2;
    if(a[i]==b[i]) b[i] = 0;
    else b[i] = 1;
  }
  int cnt=0;
  rep(i,n+1) {
    if(b[i]==1) cnt++;
  }
  cout << cnt << endl;
  rep(i,n+1){
    if(b[i]==1) cout << i << endl;
  }
}


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

#define ld			long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii 		cout << "hii" << endl
#define okay 		cout << "okay" << endl
#define hey 		cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int inf = 1e18;
const int mod = 1e9+7;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
} 

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int N = 1e5+5;
int arr[N];
vi adj[N];
void solve()
{
    int n, m;
    cin >> n >> m;

    rep(i, 1, n+1) cin >> arr[i];

    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }


    // rep(i, 1, n+1){
    //     for(auto it: adj[i]){
    //         cout << it << " ";
    //     }
    //     cout << endl;
    // }

    int cnt = 0;

    rep(i, 1, n+1){
        if(adj[i].size()==0){
            cnt++;
            // cout << i << endl;
            continue;
        }
        bool flag = 1;
        for(auto it: adj[i]){
            if(arr[i] <= arr[it]){
                // cout << i << endl;
                flag = 0;
            }
        }
        cnt += flag;
    }

    cout << cnt << endl;

}			 	      	   	        

int32_t main(){
	fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
    	// cout << "Case #" << i << ": ";
    	solve();
    }
    starboy1299();
}

Measured memory_bytes: 10440
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
xy1 = [None]*n
for i in range(n):
    x,y = tuple(map(int, input().split()))
    xy1[i] = (x,y,i)
xy2 = xy1[:]
xy1.sort()
xy2.sort(key=lambda x: x[1])

from collections import defaultdict
ns = defaultdict(set)
for i in range(n):
    x1,y1,i1 = xy1[i]
    x2,y2,i2 = xy2[i]
    if i>0:
        ns[i1].add((abs(x1-xy1[i-1][0]), xy1[i-1][2]))
        ns[i2].add((abs(y2-xy2[i-1][1]), xy2[i-1][2]))
    if i<n-1:
        ns[i1].add((abs(x1-xy1[i+1][0]), xy1[i+1][2]))
        ns[i2].add((abs(y2-xy2[i+1][1]), xy2[i+1][2]))
from collections import defaultdict
from heapq import heappush as hpush, heappop as hpop

def prim(ns):
    # n頂点の木, 隣接リストnsに対するプリム法
    seen = [False] * n
    seen[0] = True
    q = []
    for d,u in ns[0]:
        hpush(q, (d,u))
    val = 0
    for _ in range(n-1):
        while True:
            d,u = hpop(q)
            if not seen[u]:
                val += d
                seen[u] = True
                for d,v in ns[u]:
                    if not seen[v]:
                        hpush(q, (d,v))
                break
    return val
val = prim(ns)
print(val)

Measured memory_bytes: 141032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int BIT[400011];

void add(int A, int B) {
	while (A <= 400010) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}

int query(int A) {
	int kotae = 0;
	while (A > 0) {
		kotae = max(BIT[A], kotae);
		A -= A & -A;
	}
	return kotae;
}

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


	int N;
	cin >> N;
	int X[200000], Y[200000];
	vector<int> zenbu;
	int saidai = 0;
	int saishou = 1e9;
	int saidai2 = 0;
	int saishou2 = 1e9;
	rep(i, N) {
		int x, y;
		cin >> x >> y;
		if (x > y) swap(x, y);
		saidai = max(saidai, y);
		saidai2 = max(saidai2, x);
		saishou = min(saishou, x);
		saishou2 = min(saishou2, y);
		X[i] = x;
		Y[i] = y;
		zenbu.pb(x);
		zenbu.pb(y);
	}
	ll kotae1 = 1ll * (saidai - saishou2) * (saidai2 - saishou);

	sort(zenbu.begin(), zenbu.end());

	rep(i, N) {
		int x = lower_bound(zenbu.begin(), zenbu.end(), X[i]) - zenbu.begin() + 1;
		int y = lower_bound(zenbu.begin(), zenbu.end(), Y[i]) - zenbu.begin() + 1;
		add(1, x);
		add(x + 1, y);
	}

	int doko = lower_bound(zenbu.begin(), zenbu.end(), saishou2) - zenbu.begin() + 1;
	for (int i = 1; i <= doko; i++) {
		int k = query(i);
		ll kotae2 = 1ll * (saidai - saishou) * (zenbu[k - 1] - zenbu[i - 1]);
		kotae1 = min(kotae1, kotae2);
	}

	co(kotae1);

	Would you please return 0;
}

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

int main(){
    int n;
    cin >> n;
    int h[100010];
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    int count=0;
    int ans=0;

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

Measured memory_bytes: 3896
n,y=map(int,input().split())
f=True
for i in range(n+1):
     for j in range(n-i+1):
          k=n-i-j
          if k<0:
               continue
          y_=10000*i+5000*j+1000*k
          if y==y_:
               f=False
               print(i,j,k)
               break
     else:
          continue
     break
if f:
     print('-1 -1 -1')

Measured memory_bytes: 3060
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

m = []
for i in range(N):
    m.append(abs(X - x[i]))

# ここの計算量間に合わないでしょ...
c = m[0]
for i in range(1, N):
    if c == 1: break
    c = gcd(c, m[i])

print(c)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
    int q=0;char ch=' ';
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
    return q;
}
typedef long long LL;
const int N=100005;
LL sum,nowadd,nows,a[N],orz[N],m;int n;
int work() {
    int js=0;
    for(RI i=0;i<n;++i) {
        int b=a[i]-a[(i-1+n)%n];
        if((m-b)%n||m-b<0) return 0;
        orz[i]=(m-b)/n,js+=orz[i];
    }
    if(js!=m) return 0;
    for(RI i=0;i<n;++i) {
        nows+=orz[i],nowadd+=nows;
        if(a[i]<nowadd) return 0;
        a[i]-=nowadd;
    }
    for(RI i=0;i<n;++i) {
        nows-=orz[i],nowadd-=1LL*n*orz[i],nowadd+=nows;
        if(a[i]!=nowadd) return 0;
    }
    return 1;
}
int main()
{
    n=read();
    for(RI i=0;i<n;++i) a[i]=read(),sum+=a[i];
    if(sum%(1LL*(n+1)*n/2)) {puts("NO");return 0;}
    m=sum/(1LL*(n+1)*n/2);
    if(work()) puts("YES");
    else puts("NO");
    return 0;
}

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

using namespace std;

const long long p=1000000007;

long long modPow(long long a, long long x, long long p) {
    //calculates a^x mod p in logarithmic time.
    long long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

long long modInverse(long long a, long long p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
long long modBinomial(long long n, long long k, long long p) {
// calculates C(n,k) mod p (assuming p is prime).

    long long numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    long long denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

int main() {
    long long n,a,b;
    cin>>n>>a>>b;
    long long x1=modPow(2,n,p);
    long long x2=modBinomial(n,a,p);
    long long x3=modBinomial(n,b,p);
    x1%=p;x2%=p;x3%=p;
    long long val=(x2%p+x3%p)%p;
    long long ans=(x1%p-1-val%p+p)%p;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/*input

1 1 2
0 0 0 1
1 1 1 0
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define X first
#define Y second
#define mp make_pair
#define int long long
#define N
#define bit(x,y) ((x>>y)&1LL)
#define loop(x) for(int xv=1; xv<=x; xv++)

#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
	return os << '(' << a.first << ", " << a.second << ')';
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
	os << '[';
	for (unsigned int i = 0; i < a.size(); i++)
		os << a[i] << (i < a.size() - 1 ? ", " : "");
	os << ']';
	return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &a) {
	os << '{';
	for (typename set<T>::iterator it = a.begin(); it != a.end(); it++) {
		typename set<T>::iterator jt = it;
		os << *it << (++jt != a.end() ? ", " : "");
	}
	os << '}';
	return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &a) {
	os << "{\n";
	for (typename map<T1, T2>::iterator it = a.begin(); it != a.end(); it++) {
		typename map<T1, T2>::iterator jt = it;
		os << "  " << it->first << ": " << it->second << (++jt != a.end() ? ",\n" : "\n");
	}
	os << '}';
	return os;
}

int h, w, n;

bool imp(pair<int, int> p) {
	if (p.X == 0 || p.X == h) return true;
	if (p.Y == 0 || p.Y == w) return true;
	return false;
}

int toInt(pair<int, int> p) {
	if (p.X == 0) {
		return p.Y;
	}
	if (p.Y == w) {
		return w + p.X;
	}
	if (p.X == h) {
		return w + h + w - p.Y;
	}
	return w + h + w + h - p.X;
}

vector<pair<int, int> > event;
priority_queue<int, vector<int>, greater<int> > pq;
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> h >> w >> n;
	for (int i = 1; i <= n; i++) {
		pair<int, int> l, r;
		cin >> l.X >> l.Y >> r.X >> r.Y;
		if (!imp(l) || !imp(r)) continue;
		if (toInt(l) > toInt(r))
			swap(l, r);
		event.push_back(mp(toInt(l), toInt(r)));
		event.push_back(mp(toInt(r), toInt(r)));
	}
	sort(event.begin(), event.end());
	for (auto it : event) {
		if (it.fi == it.se) {
			pq.pop();
		}
		else {
			if (pq.empty() || it.se <= pq.top()) {
				pq.push(it.se);
			}
			else {
				cout << "NO" << endl;
				exit(0);
			}
		}
	}
	cout << "YES" << endl;
}

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

using namespace std;

const int N = 1e3 + 5 , M = 12;
int cost[N] , boxes[N] , memo[N][1 << M] , n , m;
int solve (int i , int msk) {
    if (i == m) return msk == (1 << n) - 1 ? 0 : 1e9;
    int &ret = memo[i][msk];
    if (~ret) return ret;
    ret = min(solve(i + 1 , msk) , solve(i + 1 , msk | boxes[i]) + cost[i]);
    return ret;
}

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

    cin >> n >> m;

    for (int i = 0 ;i < m ;i++) {
        int cnt;
        cin >> cost[i] >> cnt;
        while (cnt--) {
            int b;
            cin >> b;
            boxes[i] |= 1 << (b - 1);
        }
    }

    memset(memo , -1 ,sizeof memo);
    int ans = solve(0 , 0);
    if (ans == 1e9) ans = -1;
    cout << ans;
}

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

namespace ConsoleApp2
{
    using static System.Console;
    using static System.Math;

    class Program
    {
        static void Main(string[] args)
        {
            N = int.Parse(ReadLine());
            SP = new KeyValuePair<string, int>[N];
            for (int i = 0; i < N; i++)
            {
                var line = ReadLine().Split();
                SP[i] = new KeyValuePair<string, int>(line[0], int.Parse(line[1]));
            }
            Solve();
        }

        static int N;
        static KeyValuePair<string, int>[] SP;

        static void Solve()
        {
            foreach (var item in SP.Select((kv, i) => new { kv, Index = i + 1 }).OrderBy(x => x.kv.Key).ThenByDescending(x => x.kv.Value))
            {
                WriteLine(item.Index);
            }
        }
    }
}


Measured memory_bytes: 13664
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;
s(u,i,p,I){i?s(u,T[i],p),R[i]=(I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}
S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,F[1]);for(S(1,1);i++<n;)printf("%d ",P[i]);}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N){
    cin >> a.at(i);
  }
  int cnt;
  rep(i,N){
    int t = a.at(i);
    while(t%2==0){
      t /= 2;
      ++cnt;
    }
  }
  cout << cnt << endl;
}

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

using namespace std;

#define int long long

bool codejam = 0;

typedef long long li;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1;
	// int t; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
const int N = 1e5 + 55;
const int M = 1e9 + 7;
int dp[N][2];
void solve() {
	string l;
	cin >> l;
	int n = (int) l.size();
	l = '$' + l;
	dp[0][0] = 1;
	dp[0][1] = 0;
	for (int i = 1; i <= n; ++i) {
		if (l[i] == '0') {
			// NOT done
			dp[i][0] = dp[i - 1][0];
			// done
			dp[i][1] = 3 * dp[i - 1][1];
		}
		else {
			// NOT done
			dp[i][0] = 2 * dp[i - 1][0];
			// done
			dp[i][1] = 3 * dp[i - 1][1] + dp[i - 1][0];
		}
		dp[i][0] %= M;
		dp[i][1] %= M;
	}
	cout << (dp[n][0] + dp[n][1]) % M;
}	
 	

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

using namespace std;

int main() {
	vector <int> v(3);
	for (int i = 0; i < 3; i++) {
		scanf("%d", &v[i]);
	}
	int k;
	scanf("%d", &k);
	multiset <int> s;
	s.insert(v[0]);
	s.insert(v[1]);
	s.insert(v[2]);
	long long ans = 0;
	for (int i = 0; i < k; i++) {
		auto it = s.end();
		it--;
		int temp = 2 * (*it);
		s.erase(it);
		s.insert(temp);	
	}
	for (int it : s) {
		ans += it;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

type Queue struct {
	v []int
}

func NewQueue() Queue {
	return Queue{make([]int, 0)}
}

func (s *Queue) Insert(x int) {
	n := len(s.v)
	s.v = append(s.v, x)
	for i := (n - 1) / 2; i >= 0; i = (i - 1) / 2 {
		if s.v[n] > s.v[i] {
			s.v[n], s.v[i] = s.v[i], s.v[n]
		} else {
			break
		}
		n = i
	}
}

func (s *Queue) Front(w *bufio.Writer) {
	lenS := len(s.v)
	if lenS > 0 {
		w.WriteString(fmt.Sprintf("%d\n", s.v[0]))
	}
}

func (s *Queue) Dequeue() {
	lenS := len(s.v)
	if lenS > 0 {
		s.v = s.v[1:]
	}
}

func (s *Queue) GetMax(w *bufio.Writer) {
	if len(s.v) > 0 {
		w.WriteString(fmt.Sprintf("%d\n", s.v[0]))
	}
}

func (s *Queue) DeleteMax() {
	n := len(s.v) - 1
	if n < 0 {
		return
	}
	s.v[0], s.v[n] = s.v[n], s.v[0]
	s.v = s.v[:n]

	j := 1
	for i := 0; i < n && j < n; {
		if j < n-1 && s.v[j+1] > s.v[j] {
			j++
		}

		if s.v[j] > s.v[i] {
			s.v[j], s.v[i] = s.v[i], s.v[j]
			i = j
			j = 2*i + 1
		} else {
			return
		}
	}
}

func (s Queue) String() string {
	return strings.Trim(fmt.Sprint(s.v), "[]")
}

func NextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)

	n, _ := NextInt(sc)
	s := make([]Queue, n)
	for i := 0; i < n; i++ {
		s[i] = NewQueue()
	}

	q, _ := NextInt(sc)
	for i := 0; i < q; i++ {
		cmd, _ := NextInt(sc)
		t, _ := NextInt(sc)
		switch cmd {
		case 0:
			x, _ := NextInt(sc)
			s[t].Insert(x)
		case 1:
			s[t].GetMax(w)
		case 2:
			s[t].DeleteMax()
		}
		// fmt.Println(s)
	}

	w.Flush()
}



Measured memory_bytes: 10552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
int a[maxn];
int c[maxn];
int dp[1005][(1<<12)+5];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x;
        cin>>a[i]>>x;
        int temp=0;
        for(int j=1;j<=x;j++)
        {
            int y;
            cin>>y;
            y=1<<(y-1);
            temp|=y;
        }
        c[i]=temp;
    }
    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<(1<<n);j++)
        {
            dp[i][j]=1e9;
        }
    }
    dp[0][0]=0;
    for(int i=1;i<=m;i++)
    {
        for(int j=0;j<(1<<n);j++)
        {
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            int k=j|c[i];
            dp[i][k]=min(dp[i][k],dp[i-1][j]+a[i]);
        }
    }
    if(dp[m][(1<<n)-1]==1e9)
        cout<<-1<<'\n';
    else
        cout<<dp[m][(1<<n)-1]<<'\n';


}


Measured memory_bytes: 19612
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
using namespace std;

int main(){
    int n, sum, p, ans;
    int x[101];
    cin >> n;
    sum = 0;
    REP(int,i,0,n){ 
        cin >> x[i]; sum += x[i]; 
    }
    p = round((double)sum/n);

    ans = 0;
    REP(int,i,0,n) ans += (x[i]-p)*(x[i]-p);

    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX_N = 101;
const ll MAX_V = 1e5 + 10;
ll dp[MAX_N][MAX_V];

void init() {
	for (ll i = 0; i < MAX_N; i++) {
		for (ll j = 0; j < MAX_V; j++) {
			dp[i][j] = 0;
		}
	}
}

int main() {
	init();
	ll N, maxw;
	cin >> N >> maxw;
	vll W, V;
	ll i, j;
	for (i = 0; i < N; i++) {
		ll w, v;
		cin >> w >> v;
		W.push_back(w);
		V.push_back(v);
	}

	ll sumv = accumulate(V.begin(), V.end(), 0LL);

	for (j = 0; j <= sumv; j++) {
		dp[0][j] = 0;
	}
 
	for (i = 1; i <= N; i++) {
		for (j = 0; j <= sumv; j++) {
			if (j - V[i - 1] < 0) {
				dp[i][j] = dp[i - 1][j];
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - V[i - 1]] + W[i - 1]);
			}
		}
	}

	ll sumw = accumulate(W.begin(), W.end(), 0LL);
	for (j = 0; j <= sumv; j++) {
		if (dp[N][j] >= sumw - maxw) {
			cout << sumv - j << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n+5];
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	sort(a+1,a+1+n);
	int minn=0x3f3f3f3f;
	for(int i=a[1];i<=a[n];i++){
		int sum=0;
		for(int j=1;j<=n;j++){
			sum+=(i-a[j])*(i-a[j]);
		}
		minn=min(sum,minn);
	}
	cout << minn << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    K, N = input_nums()
    A = input_nums()
    dist = []
    for i in range(len(A)-1):
        dist.append(A[i+1]-A[i])
    dist.append(K+A[0]-A[-1])
    maxv = max(dist)
    print(sum(dist) - maxv)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 81164
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	cin >> n;
	vi v(n);
	REP(i, n) cin >> v[i];
	sort(ALL(v));
	cout << v[n - 1] - v[0] << endl;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
l=[a,b,c,d,e]
l1=[]
for i in l:
  if i%10>0:
    l1+=[i%10]
if len(l1)>0:
  print(sum(l)-sum(l1)+10*(len(l1)-1)+min(l1))
else:
  print(sum(l))

Measured memory_bytes: 3064
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=new int[](1_000_000);
  foreach(_; 0..n){
    int l, r; rd(l, r);
    a[l-1]++; a[r]--;
  }

  foreach(i; 1..a.length){
    a[i]+=a[i-1];
  }

  int c=0;
  foreach(e; a)if(e>0) c++;
  writeln(c);

}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

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

bool Dis[10];
int main(){
    int N, K;
    cin >> N >> K;
    for(int i=0;i<K;i++){
        int j;
        cin >> j;
        Dis[j]=true;
    }
    for(int i=N;i<10*N;i++){
        bool flg = true;
        int ii = i;
        while(ii){
            if(Dis[ii%10]) flg = false;
            ii /= 10;
        }
        if(flg){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

f = True
H[0] -= 1
for i in range(1, N):
  if H[i - 1] > H[i]:
    f = False
    break
  elif H[i - 1] < H[i]:
    H[i] -= 1

print("Yes" if f else "No")

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define N 100005
using namespace std;
int k[N],a[N],b[N];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    b[a[i]]++;
  }
  int ma=0;
  for(int i=0;i<n;i++){
    if(a[i]==0)
      k[a[i]]=b[a[i]]+b[a[i]+1];
    else
      k[a[i]]=b[a[i]-1]+b[a[i]]+b[a[i]+1];
    ma=max(k[a[i]],ma);
  }
  printf("%d\n",ma);
  return 0;
}


Measured memory_bytes: 1408
# coding: utf-8
#解法2 ヒープを使う
import heapq
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

used=[]

heap=[]

heapq.heappush(heap,(-(A[0]+B[0]+C[0]),0,0,0))
used.append((0,0,0))

for i in range(K):
    u=heapq.heappop(heap)
    if u[1]+1<=X-1:
        if not((u[1]+1,u[2],u[3]) in used):
            used.append((u[1]+1,u[2],u[3]))
            heapq.heappush(heap,(-(A[u[1]+1]+B[u[2]]+C[u[3]]),u[1]+1,u[2],u[3]))
    
    if u[2]+1<=Y-1:
        if not((u[1],u[2]+1,u[3]) in used):
            used.append((u[1],u[2]+1,u[3]))
            heapq.heappush(heap,(-(A[u[1]]+B[u[2]+1]+C[u[3]]),u[1],u[2]+1,u[3]))
    
    if u[3]+1<=Z-1:
        if not((u[1],u[2],u[3]+1) in used):
            used.append((u[1],u[2],u[3]+1))
            heapq.heappush(heap,(-(A[u[1]]+B[u[2]]+C[u[3]+1]),u[1],u[2],u[3]+1))
    print(-u[0])
    


Measured memory_bytes: 4468
from operator import itemgetter

N,M=list(map(int,input().split()))
a = []
b = []
for i in range(M):
    a1,b1=[int(i) for i in input().split()]
    a.append(a1)
    b.append(b1)

l1=[i for i, x in enumerate(b) if x == N]
l2=[i for i, x in enumerate(a) if x == 1]

try:
    s1=itemgetter(*l1)(a)
except:
    s1=[]
try:
    s2=itemgetter(*l2)(b)
except:
    s2=[]

if type(s1) is int:
    tmp=s1
    s1=(tmp,)
if type(s2) is int:
    tmp=s2
    s2=(tmp,)

if len(set(s1)&set(s2))>0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 36048
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout<<max(a*b,c*d)<<endl;
	return 0;
}


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

int main(void)
{
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; i++)
    {
        cin >> A[i];
    }

    int path = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(A[i][j] == '#') path++;
        }
    }

    if(path == H + W - 1){
        cout << "Possible"<< endl;
    } else {
        cout << "Impossible" << endl;
    }
    
    return 0;
}


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

 int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A==7&B==5&C==5){
   cout<<"YES"<<endl;
  }
  else if(A==5&B==7&C==5){
     cout<<"YES"<<endl;
 }
  else if(A==5&B==5&C==7){
   cout<<"YES"<<endl;
  }
  else{
      cout<<"NO"<<endl;
  }
  
 }

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int gcd;
  while (true) {
    int k = a % b;
    if (k == 0) {
      gcd = b;
      break;
    }
    a = b;
    b = k;
  }
  if (c % gcd == 0) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int k = fs.nextInt(), x = fs.nextInt();
		if(k*500>=x) {
			System.out.println("Yes");
		}else {
			System.out.println("No");			
		}
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

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

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 20692
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int g[5][5];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	rep(i, 3) rep(j, 3) cin >> g[i][j];	
	rep(i, 150) rep(j, 150) rep(k, 150){
		int f = 0;
		if(i == 0 && j == 1 && k == 0) f = 1;
		int v1 = g[0][0] - i, v2 = g[0][1] - i, v3 = g[0][2] - i;
		int v4 = g[1][0] - j, v5 = g[1][1] - j, v6 = g[1][2] - j;
		if(!(v1 == v4 && v2 == v5 && v3 == v6)) continue;
		int v7 = g[2][0] - k, v8 = g[2][1] - k, v9 = g[2][2] - k;
		if(v1 == v7 && v2 == v8 && v3 == v9){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <ctype.h>
using namespace std;
 
int main() {
char cs[1201];
scanf("%[^\n]",cs);
for(int i=0;cs[i]!='\0';i++){
	char c=cs[i],c2;
	if(tolower(c)!=c){
		c2=tolower(c);
	}else if(toupper(c)!=c){
		c2=toupper(c);
	}else{
		c2=c;
	}
	printf("%c",c2);
}
printf("\n");
return 0;
}


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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    string s; cin >> s;
    vector<pair<int, int>> zones;
    int start = -1;
    for (int i = 0; i < n; i++) {
        char c = s[i];
        if (c == '0') {
            if (start < 0) start = i;
            if (i == n-1) {
                zones.push_back({start, i});
            }
        } else if (c == '1') {
            if (start >= 0) {
                zones.push_back({start, i-1});
                start = -1;
            }
        }
    }
    int ans = -1;
    for (int i = 0; i < zones.size(); i++) {
        int start = zones[i].first;
        int nextStart;
        int prev;
        if (i + k < zones.size()) {
            nextStart = zones[i + k].first;
        } else {
            nextStart = n;
        }
        if (i - 1 >= 0) {
            prev = zones[i - 1].second + 1;
        } else {
            prev = 0;
        }
        ans = max(ans, nextStart - prev);
    }
    if (ans < 0) {
        cout << n << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1020
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

const int MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



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

	int M, D; cin >> M >> D;
	int ans = 0;
	FOR(m, 1, M + 1) {
		FOR(d, 1, D + 1) {
			if (d < 22)continue;
			int d2 = d % 10;
			int d1 = d / 10;
			if (d2 < 2)continue;
			if (d1*d2 == m)ans++;
		}
	}
	print(ans);
}



Measured memory_bytes: 256
import math
N = int(input())

flag = False
if N<4:
  print(1)
else:
  for i in range(N):
    for j in range(2, round(math.sqrt(N-i))+1):
        a = math.log(N-i, j)
        b = math.modf(a)
        if b[0] == 0.0 or b[0] > 0.99999:
          flag = True
          print(round(j**a))
          break
    if flag:
      break

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

long long ans;

int main() {
	long long n;
	cin >> n;
	for (long long i=1LL; i<=n; ++i){
		ans += i*((n/i + 1LL)*(n/i))/2LL;
	}
	cout << ans << endl;
	return 0;
}

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

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

using namespace std;

int to10(int p,string m){
  int ret = 0;
  string s = m;
  int coef = 1;
  for(int i=(int)s.size()-1;i>=0;i--){
    int v = s[i] - '0';
    if( 'A' <= s[i] && s[i] <= 'Z' ) v = 10 + ( s[i] - 'A' );
    if( 'a' <= s[i] && s[i] <= 'z' ) v = 36 + ( s[i] - 'a' );
    ret += coef * v;
    coef *= p;
  }
  return ret;
}

int main(){
  int n, nim = 0;
  cin >> n;
  rep(i,n) {
    int p;
    string m;
    cin >> p >> m;
    nim ^= to10(p,m);
  }  
  puts(nim?"win":"lose");
  return 0;
}

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

int main() {
  ll n,k; cin >> n >> k;
  vector<pair<int, int>> q;

  REP(i,n) {
    int a,b; cin >> a >> b;
    q.push_back(make_pair(a,b));
  }

  sort(q.begin(), q.end());
  ll sum = 0;
  REP(i,n) {
    sum+=q[i].second;
    if (k <= sum) { cout << q[i].first << endl; return 0; }
  }
  return 0;
}

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

int main() {

  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u)cout << a-1 << ' ' << b << endl;
  else cout << a << ' ' << b-1 << endl;

}


Measured memory_bytes: 256