akhauriyash/Code-Regression huggingface dataset:
//#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;



class UnionFindTree {
	using int32 = std::int_fast32_t;
	using uint32 = std::uint_fast32_t;
	std::vector<int32> tree;

public:
	UnionFindTree(uint32 size) : tree(size, -1) {}
	uint32 find(const uint32 x) {
		if (tree[x] < 0)
			return x;
		return tree[x] = (int32)find((uint32)tree[x]);
	}
	bool unite(uint32 x, uint32 y) {
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (tree[x] > tree[y])
			std::swap(x, y);
		tree[x] += tree[y];
		tree[y] = (int32)x;
		return true;
	}
	uint32 size(const uint32 x) { return (uint32)(-tree[find(x)]); }
	bool same(const uint32 x, const uint32 y) { return find(x) == find(y); }
};
namespace n91 {
	template <typename T>
	auto scan(T &d) ->
		typename std::enable_if<std::is_same<T, std::string>::value>::type {
		d = std::string();
		int c = 0;
		while (c < 'a' || 'z' < c)
			c = fgetc(stdin);
		while ('a' <= c && c <= 'z') {
			d.push_back(c);
			c = fgetc(stdin);
		}
	}
	template <typename T>
	auto scan(T &d) ->
		typename std::enable_if<std::is_same<T, double>::value>::type {
		scanf("%lf", &d);
	}
	template <typename T>
	auto scan(T &d) ->
		typename std::enable_if<std::is_signed<T>::value ==
		std::is_same<T, std::string>::value>::type {
		d = 0;
		int c = 0;
		while (c < '0' || '9' < c)
			c = fgetc(stdin);
		while ('0' <= c && c <= '9') {
			d = d * 10 + c - '0';
			c = fgetc(stdin);
		}
	}
	template <typename T>
	auto scan(T &d) ->
		typename std::enable_if<std::is_signed<T>::value !=
		std::is_same<T, double>::value>::type {
		d = 0;
		int c = 0;
		bool f = 0;
		while (c < '0' || '9' < c) {
			if (c == '-')
				f = 1;
			c = fgetc(stdin);
		}
		while ('0' <= c && c <= '9') {
			d = d * 10 + c - '0';
			c = fgetc(stdin);
		}
		if (f)
			d = -d;
	}
} // namespace n91
int main(void) {
	uint32 n, m;
	n91::scan(n);n91::scan(m);
#define SIZ 100001
	std::priority_queue<uint32, std::vector<uint32>, std::greater<uint32>> Q[SIZ], P;
	std::vector<uint32> r(n, 0), c(n);
	UnionFindTree U(n);
	for (uint32 i = 0;i < n;++i) {
		n91::scan(c[i]);
	}
	uint32 x, y;
	for (uint32 i = 0;i < m;++i) {
		n91::scan(x);n91::scan(y);
		U.unite(x, y);
	}
	for (uint32 i = 0;i < n;++i) {
		Q[U.find(i)].push(c[i]);
	}
	uint64 cost = 0, node = 0;
	for (uint32 i = 0;i < n;++i) {
		if (r[U.find(i)]) continue;
		r[U.find(i)] = 1;
		++node;
		cost += Q[U.find(i)].top();
		Q[U.find(i)].pop();
		while (!Q[U.find(i)].empty()) {
			P.push(Q[U.find(i)].top());
			Q[U.find(i)].pop();
		}
	}
	if (node == 1) {
		puts("0");
		return 0;
	}
	if (P.size() + 2 < node) {
		puts("Impossible");
		return 0;
	}
	for (uint32 i = 2;i < node;++i) {
		cost += P.top();
		P.pop();
	}
	printf("%lu\n", cost);
	return 0;
}

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

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        long ANS[] = new long[3];
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long K = sc.nextLong();
        ANS[0] = C + B;
        ANS[1] = C + A;
        ANS[2] = B + A;
        if (K % 2 == 0) {
            if (A - B > 10e+18) {
                System.out.println("Unfair");
                return;
            }
            System.out.println(A - B);
        } else {
            if (ANS[0] - ANS[1] > 10e+18) {
                System.out.println("Unfair");
                return;
            }
            System.out.println(ANS[0] - ANS[1]);
        }
    }
}

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

int main() {
  int a, a0, a1;
  int s, t;
  t=s=0;
  for (int i=0; i<5; i++) {
	cin >> a;
    a0=a % 10;
    a1=a-a0;
    if (a0>0) {
      a1+=10;
      a0=10-a0;
    }
    s = max(a0, s);
    t += a1;
    //cout << a << ":" << t << ":" << s << endl;
  }
  cout << t - s << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S =list(str(input()))
a=[]
ans=0
for i in range(10):
    for u in range(10):
        for y in range(10):
            moji=[str(i),str(u),str(y)]
            ti=0
            for t in range(N):
                if S[t]==moji[ti]:
                    ti+=1
                    if ti==3:
                        break
            if ti==3:
                ans+=1
                            
                
print(ans)

Measured memory_bytes: 74892
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin>>N;
    vector<long long int> A(N+1);
    for(int i=0;i<N+1;i++){
        cin>>A[i];
    }
    vector<long long int> B(N);
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    long long int ans=0;
    for(int i=0;i<N;i++){
        if(B[i]>=A[i]+A[i+1]){
            ans=ans+A[i]+A[i+1];
            A[i+1]=0;
        }
        else if(B[i]>A[i]){
            ans=ans+B[i];
            A[i+1]=A[i+1]-(B[i]-A[i]);
        }
        else{
            ans=ans+B[i];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main() {
   int a, b;

   scanf("%d %d", &a, &b);

   if(a > b) {
      for(int i = 0; i < a; i++) {
         printf("%d", b);

      }
   }else {
      for(int i = 0; i < b; i++) {
         printf("%d", a);

      }
   }
   return 0;
}



Measured memory_bytes: 1696
# Aizu Problem ITP_1_11_B: Dice II
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def do_roll(dice, roll):
    d1, d2, d3, d4, d5, d6 = dice
    if roll == 'E':
        return [d4, d2, d1, d6, d5, d3]
    elif roll == 'W':
        return [d3, d2, d6, d1, d5, d4]
    elif roll == 'N':
        return [d2, d6, d3, d4, d1, d5]
    elif roll == 'S':
        return [d5, d1, d3, d4, d6, d2]
    else:
        assert False, "We should never reach this point!"
    

right_pos = {(1, 2): 3, (1, 4): 2, (1, 5): 4, (1, 3): 5,
             (2, 3): 1, (2, 1): 4, (2, 4): 6, (2, 6): 3,
             (3, 1): 2, (3, 2): 6, (3, 6): 5, (3, 5): 1,
             (4, 1): 5, (4, 2): 1, (4, 6): 2, (4, 5): 6,
             (5, 1): 3, (5, 4): 1, (5, 6): 4, (5, 3): 6,
             (6, 2): 4, (6, 3): 2, (6, 5): 3, (6, 4): 5}
def get_right(dice, top, front):
    p_top = dice.index(top) + 1
    p_front = dice.index(front)  + 1
    return dice[right_pos[(p_top, p_front)] - 1]
    """
    for k in range(4):
        dice = do_roll(dice, 'S')
        if dice[:2] == [top, front]:
            return dice[2]
    for j in range(4):
        dice = do_roll(dice, 'E')
        for k in range(4):
            dice = do_roll(dice, 'S')
            if dice[:2] == [top, front]:
                return dice[2]
    for j in range(4):
        dice = do_roll(dice, 'W')
        for k in range(4):
            dice = do_roll(dice, 'S')
            if dice[:2] == [top, front]:
                return dice[2]
    """
    
dice = [int(_) for _ in input().split()]
Q = int(input())
for q in range(Q):
    top, front = [int(_) for _ in input().split()]
    print(get_right(dice[:], top, front))

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

#define IOS cin.tie(0);ios::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    IOS;
    CIN(H,W);
    vector<string> map(H);
    rep(i,H)cin>>map[i];
    vector<bool> row(H,false);
    vector<bool> colmn(W,false);
    rep(i,H){
        rep(j,W){
            if(map[i][j]=='#'){row[i]=true;colmn[j]=true;}
        }
    }
    rep(i,H){
        if(row[i]){
            rep(j,W){
                if(colmn[j])printf("%c",map[i][j]);
            }
            printf("\n");
        }
    }


    return 0;
}

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

using namespace std;

const int inf = (int)1e9;
const int N = 51;
int a[N][N], b[N][N], ans[N][N];

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> a[i][0] >> a[i][1];
	}
	for(int j = 0; j < m; j++){
		cin >> b[j][0] >> b[j][1];
	}
	for(int i = 0; i < n; i++){
		ans[i][0] = inf;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
	  	int dist = abs(a[i][0] - b[j][0]) + abs(a[i][1] - b[j][1]);
			if(dist < ans[i][0]){
				ans[i][1] = j + 1;
				ans[i][0] = dist;
			}
		}
	}
	for(int i = 0; i < n; i++){
		cout << ans[i][1] << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



ll modadd(long long a, long long b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(long long a, long long b){return a%MOD*b%MOD%MOD;}
ll modexp(long long a, long long n){if (a==0) return 0; if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(long long n){return modexp(n%MOD,MOD-2);}
ll modfact(long long n){long long res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(long long n, long long r){long long numer=1;long long denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main() {

    ll N; cin >> N;
    ll ans = modexp(10, N);
    ans = modadd(ans, -2*modexp(9,N));
    ans = modadd(ans, modexp(8,N));
    cout << ans << endl;


    return 0;
}





Measured memory_bytes: 3588
#include <iostream>
        #include <vector>
        #include <string>
         
        using namespace std;
         
        int main() {
            int n;
            cin >> n;
            vector<string> blue(n);
            for (int i = 0; i < n; i++) {
                cin >> blue[i];
            }
            int m;
            cin >> m;
            vector<string> red(m);
            for (int i = 0; i < m; i++) {
                cin >> red[i];
            }
         
            int ans = 0;
            auto calc = [&](string s) {
                int buf = 0;
                for (string t: blue) {
                    if (t == s) buf++;
                }
                for (string t: red) {
                    if (t == s) buf--;
                }
                return buf;
            };
         
            for (string t: blue) {
                ans = max(ans, calc(t));
            }
         
            cout << ans << endl;
            return 0;
        }

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 110, M = 110, mod = 1e9 + 7;

int n, k;
int res;

int main()
{
	cin >> n >> k;
	for (int i = k; i <= n + 1; i ++ )
	{
		int mina = (LL)(i - 1) * i / 2 % mod;
		int maxa = (LL)(2 * n - i + 1) * i / 2 % mod;
		res = (res + maxa - mina + 1) % mod;
	}
	
	res = (res % mod + mod) % mod;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <algorithm>
#include <list>
#include <map>
#include <cmath>
#include <string>
#include <iterator>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 26;

int largest(int a, int b){
	return (a<b)?b:a;
}


int main() {
	string s,t, u;
	int a,b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if(u == s and t == u){
		--a,--b;
		cout << a << gap << b << endl;
	}
	else if(u == s){
		--a;
		cout << a << gap << b << endl;
	}
	else{
		--b;
		cout << a << gap << b << endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}
ll modexpo(ll a, ll b, ll m) {if (b == 0) {return 1;} else if (a == 1) {return 1;} if (b % 2 == 0) {ll t = modexpo(a, b / 2, m); t = (t * t) % m; return t;} else {ll t = modexpo(a, b / 2, m); t = (t * t) % m; t = (t * a) % m; return t;}}

ll sum[3004][3004];
ll dp[3004][3004];


ll  fn(ll l, ll r, ll a[]) {
	if (l > r) {
		return 0;
	}
	if (l == r) {
		return a[l];
	}
	if (dp[l][r] != -1) {
		return dp[l][r];
	}
	ll op1 = sum[l ][r] - fn(l + 1, r, a);
	ll op2 = sum[l][r ] - fn(l, r - 1, a);
	ll ans = max(op1, op2);
	dp[l][r] = ans;
	return ans;
}

int main() {

	// taskkill /IM "cp.exe" /F
	fast
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
//#endif



	ll n;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < n; i++) {
		ll s = 0;
		for (int j = i; j < n; j++) {
			s += a[j];
			sum[i][j] = s;
		}
	}
	// for (int i = 0; i < n; i++) {
	// 	print(sum[i], n);
	// }
	ll t = sum[0][n - 1];
	ll f = fn(0, n - 1, a);
	ll s = t - f;
	ll ans = f - s;
	cout << ans;

}

Measured memory_bytes: 140032
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int MOD = (int)1e9+7;

const int INF = 1e9;
const int N = 105;
int n;
int t[N];
int v[N];
int T = 0;

int main(void) {
	//freopen("in.txt", "r", stdin);
	cin >> n;
	rep(i,0,n) {
		cin >> t[i];
	}
	rep(i,0,n) {
		cin >> v[i];
	}
	rep(i,0,n) {
		t[i] *= 2;
		v[i] *= 2;
		T += t[i];
	}
	T++;
	int maxV[T];
	rep(i,0,T) maxV[i] = INF;
	int l = 0;
	rep(i,0,n) {
		int r = l + t[i];
		rep(j,0,T) {
			if(j >= l && j <= r) {
				maxV[j] = min(maxV[j], v[i]);
			} else if(j < l) {
				maxV[j] = min(maxV[j], l-j+v[i]);
			} else if(j > r) {
				maxV[j] = min(maxV[j], j-r+v[i]);
			}
		}
		l = r;
	}
	rep(i,0,T) {
		maxV[i] = min(maxV[i],i);
		maxV[i] = min(maxV[i],T-1-i);
	}
	double ret = 0;
	rep(i,0,T-1) {
		ret += (double)(maxV[i+1]+maxV[i])/8;
	}
	cout << fixed << setprecision(12) << ret << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>

int main(int argc, char const *argv[]) {
  int n;
  std::vector<std::vector<int> > a;
  std::cin >> n; // .. 100
  a = std::vector<std::vector<int> >(n, std::vector<int>(n));
  // a_ij <= 2000, a_ij = a_ji, this graph is connected;

  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < n; j++) {
      std::cin >> a[i][j];
    }
  }

  //ALGORITHM
  std::vector<bool> found_vtx(n, false);
  // std::tuple<int,int,int> x(1,2,3);
  std::priority_queue<
    std::tuple<int,int,int>,
    std::vector<std::tuple<int, int, int> >,
    std::greater<std::tuple<int, int, int> >
  > q;

  int new_elm = 0;
  found_vtx[new_elm] = true;
  for (size_t i = 0; i < n; i++) {
    q.push(std::make_tuple(a[new_elm][i], new_elm, i));
  }
  int mst_weight = 0;
  while(!q.empty()){
    auto x = q.top(); q.pop();
    // std::cout << "e: "
    //   << std::get<0>(x) << " "
    //   << std::get<1>(x) << " "
    //   << std::get<2>(x) << std::endl;
    if(found_vtx[std::get<2>(x)] || std::get<0>(x) < 0) continue;
    else{
      mst_weight += std::get<0>(x);
      // std::cout << std::get<0>(x) << std::endl;
      new_elm = std::get<2>(x);
      found_vtx[new_elm] = true;
      for (size_t i = 0; i < n; i++) {
        q.push(std::make_tuple(a[new_elm][i], new_elm, i));
      }
    }
  }

  std::cout << mst_weight << std::endl;
  return 0;
}

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define All(x) (x).begin(), (x).end()
#define mp make_pair
#define Task "abc"

typedef long long ll;
const int maxn = 1e5 + 10;
const ll mod = 1e9 + 7;

ll f[maxn], cnt[maxn];

ll Pow(ll x, ll y){
  if (y == 0) return 1;
  ll tmp = Pow(x, y / 2);
  tmp = tmp * tmp; tmp %= mod;
  if (y % 2) return (tmp * x) % mod;
  return tmp;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  int n, k; cin >> n >> k;

  for (int i = 1; i <= k; ++i)
    for (int j = i; j <= k; j += i) ++cnt[i];

  ll ans = 0;
  for (int i = k; i > 0; --i){
    f[i] = Pow(cnt[i], n);
    for (int j = i * 2; j <= k; j += i) {
      f[i] = f[i] - f[j] + mod;
      f[i] %= mod;
    }
    ans = ans + f[i] * i;
    ans = ans % mod;
  }
  cout << ans;

return 0;
}


Measured memory_bytes: 5208
import sys
H, W = [int(i) for i in input().split(" ")]
board = [["0" for w in range(W+2)] for h in range(H+2)]

for h in range(H):
    tmp = list(input())
    for w in range(W):
        board[h+1][w+1] = tmp[w]

def printBoard():
    for h in range(H+2):
        for w in range(W+2):
            sys.stdout.write(board[h][w])
            sys.stdout.write(" ")
        sys.stdout.write("\n")

def check(h,w):
    if board[h][w-1] == "#":
        return True
    if board[h][w+1] == "#":
        return True
    if board[h-1][w] == "#":
        return True
    if board[h+1][w] == "#":
        return True
    return False

def solve():
    flag = True
    for h in range(1, H+1):
        for w in range(1, W+1):
            if board[h][w] == "#":
                flag = check(h, w)
            else:
                pass
            if not flag:
                return flag
    return flag

if solve():
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
/*
    author  : real_rpg  
    country : India
    time    : 00:51:12 IST
*/
 
#include "bits/stdc++.h" 
#define ll long long
#define ld long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fld(i,a,b,c) for(ld i=a; i<b; i+=c)
#define fl(i,a,b,c) for(ll i=a; i<b; i+=c)
#define rfl(i,a,b,c) for(ll i=a; i>=b; i-=c) 
#define endt (double)(clock() - tStart)/CLOCKS_PER_SEC
#define rep(i,n) fl(i,0,n,1)
#define rep1(i,n) fl(i,1,n,1)
#define rrep(i,n) rfl(i,n-1,0,1)
#define sas int tt; cin >> tt; rep(tc,tt) 
#define pb  push_back
#define ep emplace_back
#define F first
#define S second
using namespace std; 
const int md = 1e9 + 7;
const int MAX = 1e5 + 5;
const int MAXN = 1e6 + 5;

void solve() {
    string s; cin>>s;
    rep(i,s.length()) {
        if(s[i]=='9') {
            s[i]='1';
        } else if(s[i]=='1') {
            s[i]='9';
        }
    } cout<<s;
}

int main() {             
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); cout.tie(NULL); 
    //clock_t tStart = clock(); 
    solve(); 
    //printf("\n%.6f\n", endt);
    return 0; 
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  int d;
  vector<int> count(13,0);
  count[0]++;
  for(int i=0;i<n;i++){
    cin >> d;
    count[d]++;
  }
  if(count[0]>1||count[12]>1){
    cout << 0 << endl;
    return 0;
  }
  for(int i=1;i<12;i++){
    if(count[i]>2){
      cout << 0 << endl;
      return 0;
    }
  }
  int pre,tmp;
  int ans=0;
  for(int i=0;i<(1<<11);i++){
    vector<int> x(24,0);
    x[0]=1;
    if(count[12]) x[12]=1;
    for(int j=1;j<=11;j++){
      if(count[j]==2) x[j]=x[24-j]=1;
      else if(count[j]==1){
        if(i&(1<<(j-1))) x[j]=1;
        else x[24-j]=1;
      }
    }
    tmp=100;
    pre=0;
    for(int j=1;j<24;j++){
      if(x[j]==1){
        tmp=min(tmp,j-pre);
        pre=j;
      }
    }
    // for(int j=0;j<24;j++){
    //   cout << x[j];
    // }
    // cout << endl;
    // cout << tmp << endl;
    tmp=min(tmp,24-pre);
    ans=max(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b;

  c = a * b % 2;
  
  if (c == 1) {
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 256
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int h1,h2,m1,m2,t,T;
void solve(){
  cin>>h1>>m1>>h2>>m2>>T;
  if(h1==h2 and m1==m2)cout<<0,exit(0);
  t=((h2*60+m2)-(h1*60+m1));
  cout<<t-T;
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

int main(){
    char S[4];
    int cnt = 0;

    for (int i = 0; i < 4; i++){
        scanf("%c", &S[i]);
    }

    for (int ii = 0; ii < 4; ii++){
        if ('+' == S[ii]){
            cnt++;
        }
        else{
            cnt--;
        }
    }
    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int r;
    cin >> r;
    cout << r*r << "\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    int ans = (n - 1) / (k - 1);
    if(0 != (n - 1) % (k - 1))
    {
        ans += 1;
    }

    cout << ans;

    return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main() {
    int dx[] = {1,0,-1,0};
    int dy[] = {0,-1,0,1};
    int h, w; cin >> h >> w;

    vector<vector<char>> S(h,vector<char>(w));
    queue<pair<int,int>> startPoint;
    rep(i,h){
        rep(j,w){
            cin >> S[i][j];
            if(S[i][j] == '.')startPoint.push({i,j});
        }
    }

    int ans = 0;
    while(!startPoint.empty()){
        int Max = 0;
        vii dist(h,vi(w,-1));
        queue<pair<int,int>> que;
        int x,y;
        tie(y,x) = startPoint.front();
        que.push({y,x});
        startPoint.pop();
        dist[y][x] = 0;

        while (!que.empty()) {
            int x,y;
            tie(y,x) = que.front();
            que.pop();

            for (int i=0;i<4;i++) {
                int nx = dx[i] + x;
                int ny = dy[i] + y;
                if (nx>=w||nx<0||ny>=h||ny<0||dist[ny][nx] != -1) continue;
                if(S[ny][nx] == '#')continue;
                dist[ny][nx] = dist[y][x] + 1;
                que.push({ny,nx});
            }
        }

        for(int vy=0;vy<h;vy++){
            for(int vx=0;vx<w;vx++){
                if(S[vy][vx] == '#' || dist[vy][vx] != -1)continue;
                dist[vy][vx] = 0;
                que.push({vy,vx});
                while (!que.empty()) {
                    int x,y;
                    tie(y,x) = que.front();
                    que.pop();

                    for (int i=0;i<4;i++) {
                        int nx = dx[i] + x;
                        int ny = dy[i] + y;
                        if (nx>=w||nx<0||ny>=h||ny<0||dist[ny][nx] != -1) continue;
                        if(S[ny][nx] == '#')continue;
                        dist[ny][nx] = dist[y][x] + 1;
                        que.push({ny,nx});
                    }
                }
            }
        }

        rep(i,h){
            rep(j,w){
                chmax(Max,dist[i][j]);
            }
        }
        chmax(ans,Max);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication11 {
    class Program {

        string[] R = new string[] { "00", "00", "00", "00", "ff", "ff", "ff", "ff" };
        string[] G = new string[] { "00", "00", "ff", "ff", "00", "00", "ff", "ff" };
        string[] B = new string[] { "00", "ff", "00", "ff", "00", "ff", "00", "ff" };
        string[] name = new string[] { "black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white" };

        static void Main(string[] args) {
            new Program().solve();
        }

        void solve() {
            while (true) {
                string input = Console.ReadLine();
                if (input == "0") {
                    return;
                }
                string[] RGB = new string[3];
                RGB[0] = input.Substring(1, 2);
                RGB[1] = input.Substring(3, 2);
                RGB[2] = input.Substring(5, 2);

                int nearestIdx = 0;
                int dist = int.MaxValue;
                Color inputColor = new Color(RGB);
                for (int i = 0; i < name.Length; i++) {
                    if (inputColor.compareToOther(R[i],G[i],B[i]) < dist) {
                        dist = inputColor.compareToOther(R[i], G[i], B[i]);
                        nearestIdx = i;
                    }
                }
                Console.WriteLine(name[nearestIdx]);
            }
        }

        
    }
    class Color {
        int R;
        int G;
        int B;

        public Color(string[] RGB){
            R = Convert.ToInt32(RGB[0],16);
            G = Convert.ToInt32(RGB[1],16);
            B = Convert.ToInt32(RGB[2],16);
        }

        public int compareToOther(string oR,string oG, string oB){
            int oppR = Convert.ToInt32(oR, 16);
            int oppG = Convert.ToInt32(oG, 16);
            int oppB = Convert.ToInt32(oB, 16);
            return (R - oppR) * (R - oppR) + (G - oppG) * (G - oppG) + (B - oppB) * (B - oppB);
        }
    }
}

Measured memory_bytes: 9108
N = int(input())
L = list(map(int,input().split()))
L = sorted(L,reverse=True)

flg = 0
for i in range(N) :
    if i % 2 == 0 :
        if L[i] == N-i-1 :
            continue
        flg = 1
        break
    else :
        if L[i] == N-i :
            continue
        flg = 1
        break
if flg == 1 :
    ans = 0
else :
    ans = 2**(len(L)//2) % (10**9+7)
print(ans)


Measured memory_bytes: 13880
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    Sourav Verma IPG_2013  ABV_IIITMG Task @ Codeforces 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/    

#include<bits/stdc++.h>

#define ll                    long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll lcm(int x, int y) { return x * 1ll * y / (int)__gcd(x, y); }
ll hcf(ll a, ll b) {if(b>a) return (hcf(b, a)); if(a%b==0) return b; return (hcf(b, a%b));} 
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);
    int n,c5=0,c7=0;
    loop(i,0,3){
        cin>>n;
        if(n==5) c5++;
        else if(n==7) c7++;
        else continue;
    }
    if(c5==2 and c7==1) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

int main(){
  string S,T;
  cin >> S >> T;
  int A,B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(U == S){
    cout << A-1 << " " << B << endl;
  }else{
    cout << A << " " << B - 1 << endl;
  }
	      
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int cal(int n)
{
	int r=0;
	int m=log10(n);
	int mm = pow(10,m);
	while(mm!=1)
	{
		r+=n/mm;
		n=n%mm;
		mm/=10;
	}
	r+=n;
	return r;
}
int main()
{
	int n,a,b;
	ll ans=0;
	int num;
	cin>>n>>a>>b;
	for(int i=1;i<n+1;i++)
	{
		num = cal(i);
		//cerr<<i<<" "<<num<<endl;
		if(num>=a && num<=b)
		{
			ans+=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
N,T = input().split(' ')
ps = input().split(' ')
N=(int)(N)
T=(int)(T)

def E_cal(i):
    return (i+1)/2

Es=[]

ruiseki_sum=[0]

for i,p in enumerate(ps):
    Es.append(E_cal((int)(p)))
    ruiseki_sum.append(Es[i]+ruiseki_sum[i])

#print(Es)
#print(ruiseki_sum)
TEs_max = 0

for j in range(N-T+1):
    now = ruiseki_sum[j+T]-ruiseki_sum[j]
    if now>TEs_max:
        TEs_max=now
    #print(now)
print(TEs_max)

Measured memory_bytes: 30188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    int n;
    cin >> n;
    if(n <= 999){
        cout << "ABC" << endl;
    }
    else{
        cout << "ABD" << endl;
    }
    
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007

using namespace std;

int dp[100001];

vvi adj;

vector<bool> visited;

void dfs(int node)
{
    // Mark as visited
    visited[node] = true;

    // Traverse for all its children
    for (int i = 0; i < adj[node].size(); i++) {

        // If not visited
        if (!visited[adj[node][i]])
            dfs(adj[node][i]);

        // Store the max of the paths
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]);
    }
}

int main()
{
    IOS
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    visited.resize(n+1);
    for(int i=1;i<=n;i++)
    {
        visited[i]=false;
    }
    memset(dp,0,sizeof(dp));
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
    }
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
            dfs(i);
    }
    int maxi=0;
    for(int i=1;i<=n;i++)
    {
        maxi=max(maxi,dp[i]);
    }
    cout<<maxi;
    return 0;
}


Measured memory_bytes: 8192
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ priority_queue<ll, vector<ll>, greater<ll>>

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

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

int main() {
  ll H, W, h, w;
  vector<ll> A;
  cin >> H >> W >> h >> w;
  cout << H * W - (h * W) - (w * H) + (h * w) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  string s;
  cin >> s;
  if(s[0] != s[1] || s[0] != s[2] || s[1] != s[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int)n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 
int main(){
	//in_o();
	int n,k,q;
	cin>>n>>k>>q;
	VI a(q);
	FOR(i,0,q){
		cin>>a[i];a[i]--;
	}
	VI hsh(n,k-q);
	FOR(i,0,q){
		hsh[a[i]]++;
	}
	FOR(i,0,n){
		if(hsh[i]>0)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

//Sheets
public class Main{

	class Scanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-') return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}
	}
	
	class R{
		int x1, x2, type;
		public R(int x1, int x2, int type) {
			this.x1 = x1;
			this.x2 = x2;
			this.type = type;
		}
	}
	
	int n, r, area, len, INF = 1<<28;
	int[][] a;
	List<R>[] list;
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner();
		a = new int[2][10000];
		list = new List[10001];
		for(;;){
			n = sc.nextInt(); r = sc.nextInt();
			if((n|r)==0)break;
			int minx = INF, maxx = -1, miny = INF, maxy = -1;
			area = len = 0;
			for(int i=0;i<=10000;i++)list[i] = new ArrayList<R>();
			for(int i=0;i<n;i++){
				int x1 = sc.nextInt(), y1 = sc.nextInt(), x2 = sc.nextInt(), y2 = sc.nextInt();
				minx = Math.min(minx, x1);
				maxx = Math.max(maxx, x2);
				miny = Math.min(miny, y1);
				maxy = Math.max(maxy, y2);
				list[y1].add(new R(x1, x2, 1));
				list[y2].add(new R(x1, x2, -1));
			}
			Arrays.fill(a[0], 0);
			int X = 1;
			for(int y=miny;y<=maxy+1;y++,X=1-X){
				for(int x=minx;x<maxx;x++)a[X][x]=a[1-X][x];
				for(R r:list[y]){
					for(int x=r.x1;x<r.x2;x++)a[X][x]+=r.type;
				}
				for(int x=minx;x<maxx;x++){
					if(0 < a[X][x]){
						area++;
						if(x==0 || a[X][x-1]==0)len++;
						if(x==9999 || a[X][x+1]==0)len++;
					}
					if(a[X][x]==0&&0<a[1-X][x] || 0<a[X][x]&&a[1-X][x]==0)len++;
				}
			}
			System.out.println(area);
			if(r==2)System.out.println(len);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 14000
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int long long a,b,c;
	cin>>a>>b>>c;
	if(c<=a+b)
		cout<<"No";
	else
	{
		if(4*a*b<(c-a-b)*(c-a-b))
			cout<<"Yes";
		else
			cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
require 'pp'

h, w = gets.chomp!.split(" ").map(&:to_i)
n = gets.chomp!.to_i
a_n = gets.chomp!.split(" ").map(&:to_i)

colors = {}
a_n.each.with_index(1) do |a, i|
    colors[i] = a
end

ans = []
colors.each do |color, count|
    ans << [color] * count
end

ans.flatten.each_slice(w).with_index do |x, i|
    if i % 2 == 0
        puts x.join(" ")
    else
        puts x.reverse.join(" ")
    end
end



Measured memory_bytes: 4092
//Ahadul Haque, MBSTU,ICT
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
#define TEST int test; cin >> test ;while(test--)
#define endl "\n"
int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}



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

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

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

int main(void){

    int n, m;
    cin >> n >> m;
    ll ans = 0;
    vector<int> a(n);
    roop(i, m){
        cin >> a[i];
    }

    roop(i, m){
        ans += a[i];
    }

    cout << (n >= ans ? n-ans : -1) << endl;

    return 0;
}

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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

int n;
int cnt[9] = {};

int main()
{
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a >= 3200) cnt[8]++;
    else cnt[a/400]++;
  }

  int c = 0;
  for (int i = 0; i < 8; ++i)
    if (cnt[i] > 0) c++;

  cout << max(cnt[8]>0?1:0,c) << " " << c+cnt[8] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    const int N = 1e7+1;
    int n; cin >> n;
    vector<int> m(N);
    REP(i,n) {
        int x;
        cin >> x;
        m[x]++;
    }
    int cnt = 0;
    REP(i,N) if (m[i] != 0) cnt++; 

    cout << ( cnt % 2 == 0 ? cnt -1 : cnt ) << endl;

    return 0;
}

Measured memory_bytes: 39296
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())))

# エラトステネスの篩っぽく処理
ans_list = [True for _ in range(A[-1] + 1)]
ans = 0

# ダブリを省くために先に数える
c = Counter(A)

for a in A:
    if ans_list[a] == True:
        if c[a] == 1:
            ans += 1
        i = 2
        while a * i <= A[-1]:
            ans_list[a * i] = False
            i += 1

print(ans)


Measured memory_bytes: 44688
N = int(input())
A = list(map(int, input().split()))
# dp = [0 for _ in range(N)]

# A.sort()

# for i in range(N):
#     if dp[i] < 2:
#         p = A[i]
#         for j in range(N):
#             if dp[j] < 2 and A[j]%p == 0 and A[j] >= p:
#                 dp[j] += 1
# cnt = 0
# for i in range(N):
#     if dp[i] == 1:
#         cnt += 1
M = 10**6  + 5
cnt = [0 for _ in range(M)]
for x in A:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    i = x
    while i < M:
        cnt[i] += 1
        i += x
ans = 0
for x in A:
    if cnt[x] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 195364
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

long long n,k,a[300000],tot=1,x=0,t=0;
int f[300000],s[300000];
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i)
	  scanf("%lld",&a[i]);
	int i=1;  
	s[tot]=1;f[1]=1;
	while(1)
	  {
	  	  i=a[i];
	  	  if(f[i]==1)
	  	    {
	  	    	x=i;
	  	    	break;
	  	    }
	  	  f[i]=1;
		  s[++tot]=i;  
	  }  
    if(k<tot) printf("%d\n",s[k+1]);
	else 
	  {
	  	  if(k==tot) 
	  	  {
	  	  	  printf("%d\n",x);
	  	  	  return 0;
	  	  }
	  	  if(x==1) printf("%d\n",s[k%tot+1]);
	  	  else
	  	  {
	  	  for(int i=1;i<=tot;++i)
	  	    if(s[i]==x) t=i;  
	  	  printf("%d\n",s[(k-t+1)%(tot-t+1)+t]);
	  	  }
	  }
}


Measured memory_bytes: 6848
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::string s;

int main(void){
	int n,i,ans;
	std::cin >> s;
	n = s.l_ength();
	for(i=0; i<n; ++i){
		if(s[i]=='?'){
			s[i] = 'D';
		}
	}
	std::cout << s << std::endl;
	return 0;
}


Measured memory_bytes: 3752