akhauriyash/Code-Regression huggingface dataset:
import sys
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part
from collections import deque
H,W=MI()
route=[list(I()) for _ in range(H)]
d=deque()
for h in range(H):
    for w in range(W):
        if route[h][w]=='#':
            d.append([h,w])
cnt=0
while d:
    l=list(d)
    d.clear()
    for Y,X in l:
        for y,x in [[Y-1,X],[Y+1,X],[Y,X-1],[Y,X+1]]:
            if 0<=y<H and 0<=x<W:
                if route[y][x]=='.':
                    route[y][x]='#'
                    d.append([y,x])
    cnt+=1
print(cnt-1)

Measured memory_bytes: 204116
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

int n;
double x[50005], r[50005];

bool check(double m)
{
	vector<pair<double, int> > vec;
	for(int i = 1; i <= n; i++){
		double l = r[i]*r[i] - m*m;
		if(l <= 0) continue;
		l = sqrt(l);
		vec.push_back(make_pair(x[i]-l, 0));
		vec.push_back(make_pair(x[i]+l, 1));
	}
	sort(vec.begin(), vec.end());
	
	double mx = 0, pre; int cnt = 0;
	for(int i = 0; i < vec.size(); i++){
		if(vec[i].second == 0){
			if(cnt == 0) pre = vec[i].first;
			cnt++;
		}
		else{
			cnt--;
			if(cnt == 0) mx = max(mx, vec[i].first - pre);
		}
	}
	return mx >= m*2;
}

int main(void)
{
	while(1){
		cin >> n;
		if(n == 0) break;
		for(int i = 1; i <= n; i++) cin >> x[i] >> r[i];
		
		double ub = 1e9, lb = 0, mid;
		for(int i = 0; i < 100; i++){
			mid = (ub+lb)/2;
			if(check(mid)) lb = mid;
			else ub = mid;
		}
		double ans = ub+lb;
		printf("%.11f\n", ans);
	}
	
	return 0;
}


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

int main()
{
    string s;
    cin >> s;
    if(s[0] == '0'){
        if(s[1] != '0'){
            if(s[2] == '0'){
                if(s[3] == '0'){
                    cout << "MMYY" << endl;
                }
                else{
                    cout << "AMBIGUOUS" << endl;
                }
            }
            else if(s[2] == '1'){
                if(s[3] == '0' || s[3] == '1' || s[3] == '2'){
                    cout << "AMBIGUOUS" << endl;
                }
                else{
                    cout << "MMYY" << endl;
                }
            }
            else{
                cout << "MMYY" << endl;
            }
        }
        else{
            if(s[2] == '0'){
                if(s[3] == '0'){
                    cout << "NA" << endl;
                }
                else{
                    cout << "YYMM" << endl;
                }
            }
            else if(s[2] == '1'){
                if(s[3] == '0' || s[3] == '1' || s[3] == '2'){
                    cout << "YYMM" << endl;
                }
                else{
                    cout << "NA" << endl;
                }
            }
            else{
                cout << "NA" << endl;
            }
        }
    }
    else if(s[0] == '1'){
        if(s[1] == '0' || s[1] == '1' || s[1] == '2'){
            if(s[2] == '0'){
                if(s[3] == '0'){
                    cout << "MMYY" << endl;
                }
                else{
                    cout << "AMBIGUOUS" << endl;
                }
            }
            else if(s[2] == '1'){
                if(s[3] == '0' || s[3] == '1' || s[3] == '2'){
                    cout << "AMBIGUOUS" << endl;
                }
                else{
                    cout << "MMYY" << endl;
                }
            }
            else{
                cout << "MMYY" << endl;
            }
        }
        else{
            if(s[2] == '0'){
                if(s[3] == '0'){
                    cout << "NA" << endl;
                }
                else{
                    cout << "YYMM" << endl;
                }
            }
            else if(s[2] == '1'){
                if(s[3] == '0' || s[3] == '1' || s[3] == '2'){
                    cout << "YYMM" << endl;
                }
            }
            else{
                cout << "NA" << endl;
            }
        }
    }
    else{
            if(s[2] == '0'){
                if(s[3] == '0'){
                    cout << "NA" << endl;
                }
                else{
                    cout << "YYMM" << endl;
                }
            }
            else if(s[2] == '1'){
                if(s[3] == '0' || s[3] == '1' || s[3] == '2'){
                    cout << "YYMM" << endl;
                }
            }
            else{
                cout << "NA" << endl;
            }
        
    }

    return 0;
}

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

a=list(map(int,input().split()))


a=sorted(a)

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a



l=1
r=10**9
a.sort()
ans=[a[0],a[1]]
k=-1
nexts=0
stock=0
s_2=-1


ans=gcd(a[0],a[1])
for j in range(2,len(a)):
    if(stock!=2):
        s=gcd(ans,a[j])
        if(s<ans and stock==0):
            stock+=1
            nexts=s
        elif(s<ans and stock==1):
            if(s==nexts):
                stock-=1
                ans=s
            else:
                stock+=1
                s_2=s
                s_1=nexts
                #ans=max(s,nexts)
    else:
        s_1=gcd(s_1,a[j])
        s_2=gcd(s_2,a[j])
if(s_2==-1):
    ans1=ans
else:
    ans1=max(s_1,s_2)
    
ans=a[0]
for j in range(2,len(a)):
    ans=gcd(ans,a[j])
ans2=ans
ans=a[1]
for j in range(2,len(a)):
    ans=gcd(ans,a[j])

ans3=ans

    

print(max([ans1,ans2,ans3]))



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

int culc_GCD(int a, int b);

int main()
{
	int a, b;		//??¬?´???°????±????????????¨??????2???
	int result;		//a,b?????¬?´???°
	
	//2????????\???
	cin >> a >> b;
	
	if(a >= b)
	{
		result = culc_GCD(a, b);
	}
	else
	{
		result = culc_GCD(b, a);
	}
	
	cout << result << endl;

}

/**/
/**/
/**/
int culc_GCD(int a, int b)
{
	int temp;
	while (b != 0)
	{
		temp = a;
		a = b;
		b = temp % b;
	}
	
	return a;

}

Measured memory_bytes: 3060
import heapq as pq
from collections import deque
from itertools import accumulate
N,K = map(int,input().split())
v = list(map(int,input().split()))
acc = [0]+list(accumulate(v,lambda x,y: x+y))
anss = -1
M = min(K,N)
for k in range(M+1):
    for i in range(k+1):
        ans = 0
        ls = deque(v)
        heap = []
        j = k-i
        ans += acc[i]+acc[-1]-acc[-1-j]
        for q in range(i):
            if ls:
                pq.heappush(heap,ls.popleft())
            else:
                break
        for q in range(j):
            if ls:
                pq.heappush(heap,ls.pop())
            else:
                break
        for i in range(K-k):
            if heap:
                x = pq.heappop(heap)
                if x < 0:
                    ans -= x
                else:
                    break
        anss = max(ans,anss)
print(anss)

Measured memory_bytes: 3436
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int count = 0;
        int N = 0;
        int M = 0;
        int[] result = new int[30];

        while (scan.hasNext()) {
            if (count == 0) {
                N = scan.nextInt();
                M = scan.nextInt();
                scan.nextLine();
                count++;
                continue;
            }
            String str = scan.nextLine();
            String[] splited = str.split(" ");
            for (int j = 1; j <= Integer.parseInt(splited[0]); j++) {
                result[Integer.parseInt(splited[j]) - 1]++;
            }

            if (++count > N) {
                break;
            }
        }

        int resultCount = 0;
        for (int r : result) {
            if (r == N) {
                resultCount++;
            }
        }
        System.out.print(resultCount);
    }
}


Measured memory_bytes: 21712
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x) do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<#x<<': "';\
for(auto&e: x)cerr<<e<<" ";cerr<<"\n";}while(0)

using namespace std;
using ll=long long;

const int MM=1e5+10;
bool visited[MM];
vector<int> A[MM];

void dfs(int u) {
  visited[u] =true;
  for(auto&v: A[u]) if(!visited[v]) dfs(v);
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int N, M; cin >> N >> M;
  rep(i,0,M-1) {
    int x,y,z;
    cin >> x >> y >> z;
    A[x].push_back(y);
    A[y].push_back(x);
  }

  int ans = 0;
  rep(i,1,N) {
    if (!visited[i]) {
      ans++;
      dfs(i);
    }
  }

  cout << ans << endl;

}



Measured memory_bytes: 8960
while True:
    H, W = map(int, input().split())
    
    if H==0 and W==0 :
        break
    
    if W%2 == 0:                    #横幅が偶数
        for i in range(H):
            if (i+1)%2==1:          #奇数行目 
                print('#.'*(W//2))
            if (i+1)%2==0:          #偶数行目 
                print('.#'*(W//2))
    
    if W%2 == 1:                    #横幅が奇数
        for i in range(H):
            if (i+1)%2==1:          #奇数行目
                print('#',end='')
                print('.#'*(W//2))
            if (i+1)%2==0:          #偶数行目 
                print('.',end='')
                print('#.'*(W//2))
    
    print('')


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n;
  int b[100];
  bool ng = false;

  cin >> n;
  REP(i,n) {
    cin >> b[i];
    if (b[i] > i + 1) {
      ng = true;
    }
  }

  if (ng) {
    cout << -1 << endl;
    return 0;
  }

  // 埋まっているか
  bool isFilled[100] = {};


  REP(j,n) {
    int nowc = j + 1;
    for (int i = n-1; i > -1; i--) {
      if(!isFilled[i] && b[i] <= nowc) {
        cout << b[i] << endl;
        isFilled[i] = true;
        break;
      }
      if(isFilled[i]) {
        nowc--;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=30;
char st[MAXN][MAXN];
int sp[MAXN],ans,used[MAXN];
int n,m;
bool check()
{
	memset(used,0,sizeof(used));
	for(int i=0;i<m;i++){
		if(used[i]) continue;
		for(int j=0;j<m;j++){
			bool vis=1;
			if(i==j||used[j]) continue;
			for(int k=0;k<n;k++){
				if(st[k][i]==st[sp[k]][j]) continue;
				vis=0;
				break;
			}
			if(vis){
				used[i]=used[j]=1;
				break;
			}
		}
	}
	int cnt=0,pos=-1;
	for(int i=0;i<m;i++)
		if(!used[i]) cnt++,pos=i;
	if(cnt>=2||(cnt&&(m%2==0))) return 0;
	if(cnt==1)
		for(int i=0;i<n;i++)
			if(st[i][pos]!=st[sp[i]][pos]) return 0;
	return 1;
}
void dfs(int u,int flag)
{
	if(u==(n+1)>>1){
		if(check()) ans=1;
		return;
	}
	if(ans==1) return;
	for(int i=u;i<n;i++){
		if(sp[i]==-1){
			for(int j=i+1;j<n;j++){
				if(sp[j]==-1){
					sp[i]=j;sp[j]=i;
					dfs(u+1,flag);
					sp[i]=sp[j]=-1;
				}
			}
			if(flag){
				sp[i]=i;
				dfs(u+1,0);
				sp[i]=-1;
			}
		}
	}
}
int main()
{
	while(cin>>n>>m){
		memset(sp,-1,sizeof(sp));
		ans=0;
		for(int i=0;i<n;i++) scanf("%s",st[i]);
		if(n&1) dfs(0,1);
		else dfs(0,0);
		if(ans) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
def solve():
    k, a = read()
    result = think(k, a)
    write(result)


def read():
    n, k = read_int(2)
    a = read_int(n)
    return k, a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(k, a):
    max_n = 100

    # dp[i] = True/False; True means First player win if num of stone is i
    dp = [False] * (k + max_n + 1)

    for i in range(len(dp)):
        for elem in a:
            if i >= elem:
                dp[i] |= not dp[i - elem]

    return dp[k]


def write(result):
    if result:
        print('First')
    else:
        print('Second')


if __name__ == '__main__':
    solve()

Measured memory_bytes: 40436
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
  sort(all(S));
  if(S[0]=='a'&&S[1]=='b'&&S[2]=='c'){
    op(YES);return;
  }
  op(NO);
  return;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			// Generics の 配列は作れない　
			// ArrayList<Integer>[] A = new ArrayList<Integer>[0];
			ArrayList<ArrayList<Integer>> A = new ArrayList<>();
			int n = sc.nextInt();
			for(int i = 0; i < n; i++) {
				A.add(new ArrayList<Integer>());
			}
			int qn = sc.nextInt();
			for(int i = 0; i < qn; i++) {
				int q = sc.nextInt();
				switch(q) {  // 文字列に対し switch を使って良い
				case 0 /* pushBack*/: {
					int t = sc.nextInt();
					int x = sc.nextInt();
					A.get(t).add(x);
					break;  /* break を忘れない */
				}
				case 1 /* dump(t) */: {
					int t = sc.nextInt();
					String s = A.get(t).toString();
					/* [1, 2, 3] の形式なので、replace で余分な文字を取り除く */
					s = s.replaceAll("[\\[\\],]", "");
					System.out.println(s);
					break;  /* break を忘れない */
				}
				case 2: /* clear */ {
					int t = sc.nextInt();
					A.get(t).clear();
					break;  /* break を忘れない */
				}
				}
			}
		}
	}
}



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

int MAX = 2010;
int MOD = 1000000007;
vector<long long int> fac(MAX), finv(MAX), inv(MAX);

void COMinit() {
  fac.at(0) = 1;
  fac.at(1) = 1;
  finv.at(0) = 1;
  finv.at(1) = 1;
  inv.at(1) = 1;
  for (int i = 2; i < MAX; i++) {
    fac.at(i) = fac.at(i - 1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
  }
}

long long int COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac.at(n) * (finv.at(k) * finv.at(n - k) % MOD) % MOD;
}

int main() {
  int N, K;
  cin >> N >> K;
  COMinit();
  for (int i = 1; i <= K; i++) {
    long long int ans = COM(K - 1, i - 1) * COM(N - K + 1, i) % MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
//20190707
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(void){

    int n, l;

    cin >> n >> l;

    int q[n];

    int sum = 0;
    int min_num = 2000;
    int num = 0;

    for(int i=0;i<n;i++){
        q[i] = l+i;
        sum += q[i];
        if(min_num>abs(q[i])){
            min_num = abs(q[i]);
            num = i;
        }
    }

    sum -= q[num];

    cout << sum << endl;

    return 0;
}




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

int A[3][3];

int bingo(int num){
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (A[i][j] == num) A[i][j] = -1;
    }
  }
  return 0;
}

bool judge(int a, int b, int c) {
  if (a == -1 && b == -1 && c == -1) return true;
  else return false;
}

int main() {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
    }
  }

  int N; cin >> N;
  int num;
  for (int i = 0; i < N; i++) {
    cin >> num;
    bingo(num);
  }

  bool ans = false;
  if (!ans) ans = judge(A[0][0], A[0][1], A[0][2]);
  if (!ans) ans = judge(A[1][0], A[1][1], A[1][2]);
  if (!ans) ans = judge(A[2][0], A[2][1], A[2][2]);

  if (!ans) ans = judge(A[0][0], A[1][0], A[2][0]);
  if (!ans) ans = judge(A[0][1], A[1][1], A[2][1]);
  if (!ans) ans = judge(A[0][2], A[1][2], A[2][2]);

  if (!ans) ans = judge(A[0][0], A[1][1], A[2][2]);
  if (!ans) ans = judge(A[0][2], A[1][1], A[2][0]);

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,A[100005];
int mx[100005];
signed main(){
	cin>>N;
	rep(i,N+1)cin>>A[i];
	int now=1;
	rep(i,N+1){
		now-=A[i];
		if(now<0){
			cout<<-1<<endl;return 0;
		}
		chmin(now,inf);
		mx[i]=now;
		now*=2;
	}
	int ans=0;now=0;
	for(int i=N;i>0;i--){
		now+=A[i];
		ans+=now;
		if(mx[i-1]*2<now){
			cout<<-1<<endl;return 0;
		}
		now=min(mx[i-1],now);
	}
	cout<<ans+1<<endl;
}


Measured memory_bytes: 5184
// Problem : A - Don't be late
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
const long long int  modu=1e9+7;
#define endl '\n'
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define inp(x)  for(auto &t:x) cin>>t;
#define itr     vector<int>::iterator
#define debug(a) cout << #a << "=" << a << ' '<<endl;
#define out(x)  for(auto &t:x) cout<<t<<" "; cout<<endl;
#define ff first
#define ss second
#define pb push_back
#define initialize(a,v)  for(int i=0;i<a.size();++i) a[i]=v;
#define all(x) x.begin(),x.end()
#define mpt(mp) for(auto it=mp.begin();it!=mp.end();it++)
#define trav(x) for(int i=0;i<(int)x.size();++i)
#define mkp(a,b) make_pair(a,b)
#define sz(x)  (int)x.size()

int noofdig(int N)
{
	return floor(log10(N))+1;
}


ll f(ll a)
{

return 0;

}



void pre()
{

}



void solve()
{
	double d,t,s;
	cin>>d>>t>>s;
	double time_taken=d/s;
	if(time_taken<=t)
	{
		cout<<"Yes"<<endl;
	}
	else
	cout<<"No"<<endl;
	






}



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

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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


int main() {
  int a,b,n;
  cin >> n;
  for(b=1;b<=9;b++)
    {
        for(a=1;a<=9;a++)
            {
                if(n==a*b)
                {
                    cout << "Yes";
                    return 0;
                }
            }
        
    }
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lld s,d,t;
    cin>>d>>t>>s;
    if(s*t>=d)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <chrono>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;
bool solve(vector<int> & a) {
    auto start = chrono::system_clock::now();
    int n = a.size();
    const ll nc2 = n*(n+1ll)/2;
    const ll sum_a = whole(accumulate, a, 0ll);
    if (sum_a % nc2 != 0) return false;
    repeat (q, sum_a / nc2) {
        int i = whole(min_element, a) - a.begin();
        if (a[i] <= 0) break;
        repeat      (k,i)   a[k] -= (n+k)-i+1;
        repeat_from (k,i,n) a[k] -=    k -i+1;
        if (q % 10 == 0) {
            auto end = chrono::system_clock::now();
            double t = chrono::duration<double>(end - start).count();
            if (t > 1.9) {
                return true;
                // random_device device;
                // uniform_int_distribution<int> dist(0, 1);
                // return dist(device);
            }
        }
    }
    return whole(count, a, 0) == n;
}
int main() {
    int n; cin >> n;
    vector<int> a(n); repeat (i,n) cin >> a[i];
    cout << (solve(a) ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}



int main(){
	int l,r; cin >> l >> r;

	std::vector<int> v;

	for (int i = 0; i <= min(4500,r-l); ++i)
	{
		v.push_back(  (l + i) % 2019  );
	}

	std::vector<int> Ans;
	for (int i = 0; i < (int)v.size() - 1; ++i)
	{
		for (int j = i + 1; j < (int)v.size(); ++j)
		{
			Ans.push_back(  (v[i]*v[j]) % 2019  );
		}
	}

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

	cout << Ans[0] << endl;
}

Measured memory_bytes: 67972
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    int i,j,k,n,ans=0,l[101]={};
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&l[i]);
    }
    for(i=0; i<n-2; i++){
        for(j=i+1; j<n-1; j++){
            for(k=j+1; k<n; k++){
                if(l[i]!=l[j] && l[j]!=l[k] && l[k]!= l[i]){
                    if(l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j])ans++;
                }
            }
        }
    }
    printf("%d",ans);
    return 0;
}

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

using ll = long long;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (a <= k) {
        printf("%lld %lld\n", 0ll, max(0ll, b - (k - a)));
    }
    else {
        printf("%lld %lld\n", max(0ll, a - k), b);
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int N,i,j,v,n;
  scanf("%d",&N);
  int A[N];
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(n=0;n<N;n++){
    printf("%d",A[n]);
    if(n<N-1)printf(" ");
  }
  printf("\n");
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    for(n=0;n<N;n++){
      printf("%d",A[n]);
      if(n<N-1)printf(" ");
    }
    printf("\n");
  }  
  return 0;
}

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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){
    int a,b,x;
    cin >> a >> b >> x;
    if(a<=x&&a+b>=x){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

// 制約上限のn=50で考える。
// 0,1,...,49を初期状態として、操作を逆順で行っていくことを考える。
// 最も小さい物にnを加え、それ以外から-1する。
// （加えたものは最も大きくなっている必要があり、かつ-1したものは負値となってはいけない。）
// 50回繰り返すごとに全体が+1される操作となることがわかる。

int main(){
    Init();
    ll k; cin >> k;
    ll n = 50;

    // 50回の操作（全体が+1される操作）を何回行うかと、端数分
    ll q = k/50;
    ll r = k%50;
    vi a(n);

    // 初期値は0,1,...,49に50回の操作が行われる回数を加えておく
    rep(i, n) a[i] = i+q;

    // 端数分の処理
    rep(i, r) rep(j, n) (i == j) ? a[j] += n : a[j]--;

    // 出力
    cout << n << endl;
    for(ll i=0; i<a.size(); i++) cout << a[i] << (i==a.size()-1 ? endl : " ");
}

Measured memory_bytes: 3664
s = input()

if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

if len(s) < 26:
    for i in "abcdefghijklmnopqrstuvwxyz":
        if i not in s:
            print(s+i)
            exit()

else:
    s = list(s)
    t = []
    for i in range(len(s)):
        t.append(s[-1-i])
        t.sort(reverse=True)
        if t != s[-1-i:]:
            l = s[-1-i]
            for j in range(ord(l)-ord("a")+1,26):
                if chr(j+ord("a")) in t:
                    l = [chr(j+ord("a"))]
                    break
            for j in range(i+1,len(s)):
                l.append(s[-1-j])
            print(*l[::-1],sep="")
            exit()
    print(chr(ord(s[0])+1))

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main() {
  ll l,r;
  cin >> l >> r;
  r=min(r,l+2019);
  int ans=2019;
  for(ll i=l;i<=r;++i) {
    for(ll j=i+1;j<=r;++j) {
      int x=i*j%2019;
      ans=min(ans,x);
    }}
  cout << ans << endl;
  return 0;
}
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#include <math.h>
#define rep(i,s,n) for (int i = s; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;

int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;

#define LL long long;

int main() {
	double a, b, c;
	cin >> a >> b >> c;
	if (a / c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MAX_DIGIT = 50;
long long dp[100][2]; // dp[上から i 桁まで][ smaller ]

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  memset(dp, -1, sizeof(dp)); // DP 配列を -1 で初期化
  dp[0][0] = 0; // 初期条件
  for (int d = 0; d < MAX_DIGIT; ++d) {
    long long mask = 1LL<<(MAX_DIGIT - d - 1);
  
    // A で元々 d 桁目にビットが立っているものの個数
    int num = 0;
    for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;
     
    // X の d 桁目を 0, 1 にしたときのコスト
    long long cost0 = mask * num;
    long long cost1 = mask * (N - num);
        
    // smaller -> smaller
    if (dp[d][1] != -1) {
      chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1)); // 0 でも 1 でも自在に大きい方
    }
        
    // exact -> smaller
    if (dp[d][0] != -1) {
      if (K & mask) { // K の d 桁目が 1 だったら、X の d 桁目は 0 にする
        chmax(dp[d+1][1], dp[d][0] + cost0);
      }
    }
        
    // exact -> exact (K にぴったり合わせる)
    if (dp[d][0] != -1) {
      if (K & mask) chmax(dp[d+1][0], dp[d][0] + cost1);
      else chmax(dp[d+1][0], dp[d][0] + cost0);
    }
  }
  cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-6
#define inf LLONG_MAX
using namespace std;

int main() {
	speed;
	int n;
	double s = 0;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	sort(v.begin(), v.end());
	s = (v[0] + v[1]) / 2.0;
	for (int i = 2; i < n; ++i)
		s = (s + v[i]) / 2.0;
	cout << s;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long X, K, D;
    cin >> X >> K >> D;
    long long T = min(K, abs(X) / D);
    K -= T;
    if (X < 0) {
        X += D * T;
        if (K % 2 == 1) {
            X += D;
        }
    } else {
        X -= D * T;
        if (K % 2 == 1) {
            X -= D;
        }
    }
    cout << abs(X) << '\n';
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> P;
#define mp(x, y) make_pair(x, y)

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

ll f(ll x) {
	ll cnt = 0;

	for (ll i = 1; i * i <= x; i++) {
		if (x % i == 0) cnt++;
		if (x % i == 0 && i * i != x) cnt++;
	}

	return cnt;
}

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

	ll ans = 0;

	//cout << f(n) << endl;
	
	for (ll j = 1; j <= n; j++) {
		//jの倍数はqコあるよ
		ll q = n / j;
		//jの倍数 * jはj + 2 * j + ・・・ + q * j
		// = q * (q + 1) / 2 * j
		ans += j * q * (q + 1) / 2;
	}
	
	cout << ans << endl;
}



Measured memory_bytes: 3616
#include <iostream>
#include <string>
using namespace std ;
int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) {
        a -= 1;
    } else if (t == u){
        b -= 1;
    }
    cout << a << ' ' << b;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A = []

for i in range(N):
    new = int(input())
    A.append(new)

A.sort()
A.append(0)

start=A[0]
cnt=1
anscnt=0

for i in range(1,len(A)):

    if A[i]==start:
        cnt+=1
    elif A[i]!=start:
        if cnt%2==0:
            anscnt+=cnt
        elif cnt%2!=0:
            anscnt+=cnt-1    
        cnt=1
        start=A[i]


print(N-anscnt)


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


int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a<=2*b){
        ans=0;
    }
    else{
        ans=a-2*b;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

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)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;
int N;
int A[MAX];

int main(void) {
    cin >> N;
    REP(i, N) cin >> A[i];
    if (A[0]) {
        cout << -1 << endl;
        return 0;
    }
    REP(i, N - 1) {
        if (A[i] < A[i + 1] && A[i + 1] - A[i] > 1) {
            cout << -1 << endl;
            return 0;
        }
    }
    LL ans = 0;
    REP(i, N - 1) {
        if (A[i] < A[i + 1]) {
            ans++;
        } else {
            // A[i] >= A[i + 1]
            ans += A[i + 1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0505 : Questionnaire**/

int main()
{
	int N, M;
	while (cin>>N>>M, N||M) {
		vector<P> v(M);
		rep(i, M) {
			v[i].second = -(i+1);
			v[i].first = 0;
		}
		
		rep(i, N) {
			rep(j, M) {
				int a;cin>>a;
				if (a==1)
					v[j].first++;
			}
		}
		sort(v.begin(), v.end(), greater<P>());
		cout << -v[0].second;
		REP(i, 1, M) {
			cout << " " << -v[i].second;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1200
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) {
    FastReader sc = new FastReader();
	int n = sc.nextInt();
	
	if ((n%10) == (n/100)) {
		System.out.println("Yes");
	} else {
		System.out.println("No");
	}
	
  }
  
  private static long gcd(long m, long n) {
	  if (m < n) { return gcd(n, m); }
	  if (n == 0) { return m; }
	  return gcd(n, m % n);
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 23252
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int n,m;
	cin >> n;
	vll d(n);
	rep(i,n)cin >> d[i];
	cin >> m;
	vll t(m);
	rep(i,m)cin >> t[i];

	map<int,int> mpt;
	rep(i,m)mpt[t[i]]++;
	map<int,int> mpd;
	rep(i,n)mpd[d[i]]++;

	for(auto x:mpt){
		if(x.se > mpd[x.fi]){
			cout <<"NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;



	

	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://abc157.contest.atcoder.jp/tasks/abc157_c

Measured memory_bytes: 31424
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a, b) ((b) - (a))
#define length(a) (hypot((a).imag(), (a).real()))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) * (b)).imag())
#define lengthSqr(p) dot(p, p)
#define rotateO(p, ang) ((p) * exp(point(0, ang)))
#define rotateA(p, ang, about) (rotateO(vec(about, p), ang) + about)
#define reflectO(v, m) (conj((v) / (m)) * (m))
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define X() real()
#define Y() imag()
using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
typedef complex<double> point;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
	FAST_IO
	int sx, sy, ex, ey; cin >> sx >> sy >> ex >> ey;
	
	
	auto step = [&](int x, int y, int X, int Y){
		char vertical, horizontal;
		if(x < X) horizontal = 'R';
		else horizontal = 'L';
		if(y < Y) vertical = 'U';
		else vertical = 'D';
		for(int rep = 0; rep < abs(y - Y); ++rep) cout << vertical;
		for(int rep = 0; rep < abs(x - X); ++rep) cout << horizontal;
		return;
	};
	
	step(sx, sy, ex, ey);
	step(ex, ey, sx, sy);
	cout << "L";
	step(sx - 1, sy, ex, ey + 1);
	cout << "DR";
	step(ex + 1, ey, sx, sy - 1);
	cout << "U";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    //cout<<"Hello World\n";
    int input,q1,q2,dd1,output;
    cin>>input; 
    
     q1 = input/500;
     //cout<<"q1:"<<q1<<endl;
     dd1 = input - (q1*500);
     //cout<<"dd1:"<<dd1<<endl;
     q2 = dd1/5;
     //cout<<"q2:"<<q2<<endl;
     output = q1*1000+q2*5;
     cout<<output;
     
    return 0;
}

Measured memory_bytes: 256
//ABC067A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a%3 == 0 || b%3 == 0){
		cout << "Possible" << endl;
		return 0;
	}else if((a+b)%3 == 0){
		cout << "Possible" << endl;
		return 0;
	}else{
		cout << "Impossible" << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
#include <limits>

using namespace std;


int main(int argc, const char * argv[]) {
  long long n;
  cin >> n;
  long long sum = 0;

  vector<int> a(n);
  vector<int> bs(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    bs[i] = (a[i] - (i + 1));
  }
  sort(bs.begin(), bs.end());
//  cout << bs[n/2] << endl;
  for(int i = 1; i <= n; i++){
    sum += abs(a[i-1] - (bs[n/2] + i));
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, K;
	cin >> N >> K;

	string S;
	cin >> S;

	if (S[K - 1] == 'A') 	S[K - 1] = 'a';
	if (S[K - 1] == 'B') 	S[K - 1] = 'b';
	if (S[K - 1] == 'C')	S[K - 1] = 'c';

	cout << S << endl;

	//system("pause");
}

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

int main(){
  int X, Y;
  cin >> X >> Y;
  if(Y % 2 == 1){
    cout << "No" << endl;
  }
  else if(2 * X <= Y && 4 * X >= Y){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String input[] = br.readLine().split(" ");
	long a = Long.parseLong(input[0]);
	long b = Long.parseLong(input[1]);
	long c = Long.parseLong(input[2]);
	long d = Long.parseLong(input[3]);

	System.out.println(Math.max(Math.max(a * c, a * d), Math.max(b * c, b * d)));
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  
  int base = h.at(0);
  for (int i = 0; i < n; i++) {
    if (base - h.at(i) >= 2) {
      cout << "No" << endl;
      return 0;
    }
    
    if (base < h.at(i)) {
      base = h.at(i);
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 640
use std::io;
use std::cmp;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("failed to read a line");
    buf
}

fn read_ints() -> Vec<i32> {
    let line = read_line();
    let line = line.trim();
    let mut buf = vec![];
    for item in line.split(' ') {
        let parsed: i32 = item.parse().expect("failed to parse int");
        buf.push(parsed)
    }
    buf
}

fn main() {
    let prices = read_ints();
    let max_price = prices.iter().fold(0, |cur, &elem| cmp::max(cur, elem));
    let sum_price = prices.iter().fold(0, |a, b| a + b);
    let ans = sum_price - max_price;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC105D()
{
	int N, M;
	cin >> N >> M;

	vector<int> A(N + 1);
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i + 1];
		A[i + 1] %= M;
	}
	for (int i = 1; i <= N; ++i)
	{
		A[i] = (A[i - 1] + A[i]) % M;
	}
	map<int, int> xx;
	for (auto& x : A)
	{
		++xx[x];
	}

	ll ret = 0;
	for (auto& x : xx)
	{
		int n = x.second;
		ll y = n % 2 == 0 ? n / 2 : n;
		y *= n % 2 == 0 ? n - 1 : (n - 1) / 2;
		ret += y;
	}

	cout << ret << endl;

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


Measured memory_bytes: 3584
require 'set'

N, M = gets.split.map(&:to_i)

H = gets.split.map(&:to_i)

n = M.times.inject(Set.new) do |s|
  a, b = gets.split.map(&:to_i)

  if H[a - 1] < H[b - 1]
    s << a
  elsif H[a - 1] > H[b - 1]
    s << b
  else
    s << a
    s << b
  end
end

puts N - n.size

Measured memory_bytes: 22140
n, k = gets.split.map(&:to_i)
arr = []
k.times do
  _ = gets.to_i
  got = gets.split.map(&:to_i)
  arr += got
  arr.uniq!
end

cnt = 0
(1..n).each do |a|
  cnt += 1 unless arr.include?(a)
end

puts cnt


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<int>> ABC(N, vector<int>(3));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> ABC[i][j];
    }
  }
  vector<vector<int>> dp(N + 1, vector<int>(3, 0));
  for (int i = 0; i < 3; i++)
    dp[0][i] = ABC[0][i];
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < 3; j++) {
      dp[i + 1][(j + 1) % 3] =
          max(dp[i + 1][(j + 1) % 3], dp[i][j] + ABC[i + 1][(j + 1) % 3]);
      dp[i + 1][(j + 2) % 3] =
          max(dp[i + 1][(j + 2) % 3], dp[i][j] + ABC[i + 1][(j + 2) % 3]);
    }
  }
  int res = 0;
  for (int i = 0; i < 3; i++)
    res = max(res, dp[N - 1][i]);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 11264