akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<pair<int,int> >a(n);
  for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
  if(n==1)
  {
    cout<<1<<endl;
    return 0;
  }
  set<pair<int,int> >s;
  for(int i=0;i<n-1;i++)
  {
    for(int j=i+1;j<n;j++)s.insert({(a[i].first-a[j].first),(a[i].second-a[j].second)});
  }
  int ans=50;
  for(auto x: s)
  {
    //cout<<x.first<<" "<<x.second<<endl;
    vector<vector<int> >adj(n);
    int count=0;
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
      {
        if(i==j)continue;
        if((a[i].first-a[j].first)==x.first && (a[i].second-a[j].second)==x.second)
        {
          if(adj[j].size()>0 && adj[j][0]==i)continue;
          adj[i].push_back(j);
          count++;
          break;
        }
      }
    }
    //cout<<count<<endl;
    if(ans>(n-count))ans=n-count;
  }
  cout<<ans<<endl;
  return 0;
}

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

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

  ll N; cin >> N;
  ll X; cin >> X; X--;
  ll Y; cin >> Y; Y--;
  vector<ll> ans(N, 0);
  for (ll i = 0; i < N; i++) {
    for (ll j = i + 1; j < N; j++) {
      ll temp1 = j - i;
      ll temp2 = abs(X - i) + 1 + abs(Y - j);
      ll temp = min(temp1, temp2);
      // cout << i << ' ' << j << ' ' << temp << '\n';
      ans[temp]++;
    }
  }
  for (ll i = 1; i < N; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 384
rect :: [String] -> [String]
rect (h:w:_) =  (\(x:y:_) -> replicate x $ replicate y '#') $ [read h, read w] 

main=do
    xs <- fmap (map words . lines) getContents
    mapM putStrLn . map unlines . map rect $ takeWhile (\(h:_:_) -> h/="0") xs


Measured memory_bytes: 4640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int A, B, C, D;
int main () {
  cin >> A >> B >> C >> D;

  cout << min(A,B) + min(C, D) << endl;
  return 0;
}


Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    int cnt[N];
    void main()
	{
		int mx=0;int n=qread();fo(i,1,n) {int t=qread();cnt[t]++;chmax(mx,t);
			if(i==1 and t!=0)
			{
				puts("0");return;
			}
		}
		ll ans=(cnt[0]==1);fo(i,1,mx) ans=ans*qpower(cnt[i-1],cnt[i])%MOD;write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

using namespace std;

char S[111][111];
int D[111][111];
int n, m;

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

	int i, j;

	cin >> n >> m;

	for(i = 0; i < n; i ++){
		cin >> S[i];
	}

	for(i = 0; i < n; i ++){
		for(j = 0; j < m; j ++){
			if(!i && !j) D[i][j] = (S[i][j] == '#');
			else if(!i) D[i][j] = D[i][j - 1] + (S[i][j] != S[i][j - 1]);
			else if(!j) D[i][j] = D[i - 1][j] + (S[i][j] != S[i - 1][j]);
			else D[i][j] = min(D[i][j - 1] + (S[i][j] != S[i][j - 1]),
				D[i - 1][j] + (S[i][j] != S[i - 1][j]));
		}
	}
	if(S[n - 1][m - 1] == '#') D[n - 1][m - 1] ++;

	cout << (D[n - 1][m - 1] >> 1) << "\n";

	return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
const int M = 1e9 + 7;


bool cmp(pair<int, int> &a, pair<int, int> &b) {
    if (a.second == b.second)
        return a.first < b.first;
    else return a.second < b.second;
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    sort(all(v), cmp);
//
//    for (auto x : v)
//        cout << x.first << " " << x.second << endl;
    int c = 0;
    for (int j = 0; j < n; ++j) {
        c += v[j].first;
        if (c > v[j].second)
            return cout << "No" << endl, 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;
  vll A(N);
  rep(i, N) {
    cin >> A[i];
  }

  SORT(A);

  ll a = 0;
  ll b = 0;
  rep(i, N) {
    if (i % 2 == 0) {
      a += A[i];
    } else {
      b += A[i];
    }
  }

  COUT(abs(b - a));

  return 0;
}

Measured memory_bytes: 3596
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

x, a = ril()
print(0 if x < a else 10)

Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    wari = True
    for ix, a in enumerate(A):
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                continue
            else:
                wari = False
                break
    if wari:
        print("APPROVED")
    else:
        print("DENIED")
main()



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

using namespace std;
typedef long long ll;
#define debug(x) cerr << x << "\n"
#define all(x) (x).begin(),(x).end()
#define exist(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m, a, b;
    cin >> n >> m;
    map<int, multiset<int>> road;
    for(int i = 0;i<m;i++){
        cin >> a >> b;
        try {
            road.at(a).insert(b);
        }
        catch(out_of_range e) {
            road.emplace(a, multiset<int>());
            road.at(a).insert(b);
        }
        try {
            road.at(b).insert(a);
        }
        catch(out_of_range e) {
            road.emplace(b, multiset<int>());
            road.at(b).insert(a);
        }
    }
    vector<int> ans = vector<int>(n, 0);
    for (auto& k: road) {
        ans.at(k.first-1) = k.second.size();
    }
    for (int v: ans) {
        cout << v << "\n";
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

const int NMAX = 200003;

ll aint[4 * NMAX];

void update(ll val, int pos, int node, int le, int ri) {
    if(le == ri)
        aint[node] = max(aint[node], val);
    else {
        int mid = (le + ri) / 2;
        if(pos <= mid)
            update(val, pos, node * 2, le, mid);
        else
            update(val, pos, node * 2 + 1, mid + 1, ri);
        aint[node] = max(aint[node * 2], aint[node * 2 + 1]);
    }
}

ll query(int from, int to, int node, int le, int ri) {
    if(from <= le && ri <= to)
        return aint[node];

    int mid = (le + ri) / 2;
    ll ans = 0;
    if(from <= mid);
        ans = query(from, to, node * 2, le, mid);
    if(mid < to)
        ans = max(ans, query(from, to, node * 2 + 1, mid + 1, ri));
    return ans;
}

int main() {
    ios::sync_with_stdio(false);

    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    int n;
    cin >> n;
    vector<int> h(n + 1, 0);
    for(int i = 1; i <= n; i ++)
        cin >> h[i];
    vector<ll> a(n + 1, 0);
    for(int i = 1; i <= n; i ++)
        cin >> a[i];

    vector<ll> dp(n + 1, 0);
    ll ans = 0;
    for(int i = 1; i <= n; i ++) {
        dp[i] = a[i] + query(0, h[i] - 1, 1, 0, n);
        update(dp[i], h[i], 1, 0, n);

        ans = max(dp[i], ans);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 10368
import Data.List

main :: IO ()
main = do
    str <- getLine
    let num = read str :: Int
    let hour = num `div` 3600
    let minute = (num `mod` 3600) `div` 60
    let second = num `mod` 60
    putStrLn $ intercalate ":" $ map show [hour, minute, second]

Measured memory_bytes: 3540
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

int N, M; char S[15][15],T[15][15];
vector<pair<int, int> > pick;
int chk[15];

void go(int r)
{
	if (r <= 1) {
		int x = -1;
		for (int i = 0; i < N; i++) if (chk[i] == 2) x = i;
		int v = 0;
		for (int i = 0; i < pick.size(); i++) {
			for (int j = 0; j < M; j++) T[v][j] = S[pick[i].first][j];
			v++;
		}
		if (x >= 0) {
			for (int j = 0; j < M; j++) T[v][j] = S[x][j];
			v++;
		}
		for (int i = (int)pick.size() - 1; i >= 0; i--) {
			for (int j = 0; j < M; j++) T[v][j] = S[pick[i].second][j];
			v++;
		}

		vector<string> p;
		for (int j = 0; j < M; j++) {
			string u;
			for (int i = 0; i < N; i++) u += T[i][j];
			p.push_back(u);
		}

		for (int i = 0; i < p.size(); i++) {
			string v = p[i];
			reverse(v.begin(), v.end());
			for (int j = i + 1; j < p.size(); j++) {
				if (v == p[j]) {
					p.erase(p.begin() + j);
					p.erase(p.begin() + i);
					i--;
					break;
				}
			}
		}

		if (p.size() == 1) {
			string v = p[0];
			reverse(v.begin(), v.end());
			if (p[0] != v) return;
		}

		if (p.size() <= 1) {
			puts("YES");
			exit(0);
		}
	}
	else {
		int s;
		for (int i = 0; i < N; i++) if (!chk[i]) { s = i; break; }
		chk[s] = 1;
		for (int i = s + 1; i < N; i++) if (!chk[i]) {
			chk[i] = 1;
			pick.push_back({ s,i });
			go(r - 2);
			pick.pop_back();
			chk[i] = 0;
		}
		chk[s] = 0;
	}
}

void proc()
{
	scanf("%d %d", &N, &M);
	for (int i = 0; i < N; i++) scanf("%s", S[i]);
	if (N % 2) {
		for (int i = 0; i < N; i++) {
			chk[i] = 2;
			go(N - 1);
			chk[i] = 0;
		}
	}
	else go(N);
	puts("NO");
}

int main()
{
#ifdef __LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	proc();
	return 0;
}

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int calc_digit(ll num) {
    int cnt = 0;
    while(num){
        num/=10;
        cnt++;
    }
    return cnt;
}

int F(ll A, ll B){
    return max(calc_digit(A), calc_digit(B));
}

int main(){
    ll N;
    cin >> N;

    int ans = 100;
    ll for_max = N;
    for (ll i=1; i*i <= N; i++){
        if (N%i==0) {
            ans = min(ans, F(i, N/i));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, a, b, c; scanf("%d%d%d%d", &n, &a, &b, &c);
	
	printf("%d\n", n - (a + b - c));
	return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int x,a,b;
    cin >> x >> a >>b;
    cout << (abs(x-a)<abs(x-b) ? "A":"B") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

string x;
cin>>x;
if (x=="A"){
    cout<<"T";
}
else if (x=="T"){
    cout<<"A";
}
else if (x=="G"){
    cout<<"C";
}
else if (x=="C"){
    cout<<"G";
}
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    map<int,int> m;
    rep(i,n) {
        int a;
        cin >> a;
        m[a]++;
        m[a-1]++;
        m[a+1]++;
    }
    int ans = 0;
    for(auto p : m) chmax(ans,p.second);
    cout << ans << endl;
}

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

using namespace std;

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

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

    for (auto &x:mp) {
        cout << x.second << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 5504
#include<stdio.h>

//int lenth(char str[]);
int judge(char str1[], char str2[], int index);

int main(void)
{
		int n;
		int i;
		int taro_PT = 0;
		int hanako_PT = 0;
		char taro[1000][1000];
		char hanako[1000][1000];

		int CASE;

		scanf("%d", &n);
		for(i=0; i<n; i++)
		{
				scanf("%s %s", taro[i], hanako[i]);
		}

		for(i=0; i<n; i++)
		{
				CASE = judge(taro[i], hanako[i], 0);
				switch(CASE)
				{
						case 0:
						taro_PT += 3;
						break;

						case 1:
						hanako_PT += 3;
						break;

						case 2:
						taro_PT += 1;
						hanako_PT += 1;
						break;
				}
		}

		printf("%d %d\n", taro_PT, hanako_PT);
		return 0;
}
		
int judge(char str1[], char str2[], int index)
{
		int lenth1, lenth2;
		int x;

		//Taro Win
		if(str1[index] > str2[index])
		{
				return 0;
		}
		//Hanako Win
		else if(str1[index] < str2[index])
		{
				return 1;
		}
		//Same
		else if(str1[index] == str2[index])
		{
				if(str1[index] == '\0' && str2[index] == '\0')
				{
						return 2;
				}
				else
				{
						return judge(str1, str2, index+1);
				}
		}
}

Measured memory_bytes: 2548
from collections import defaultdict, deque
N = int(input())
dic = defaultdict(list)
for i in range(N-1):
  a, b, c = map(int, input().split())
  dic[a-1] += [(b-1,c)]
  dic[b-1] += [(a-1,c)]
Q, K = map(int, input().split())
deq = deque([(K-1,0)])
dist = [-1]*N
while deq:
  p, d = deq.popleft()
  for e, dd in dic[p]:
    if dist[e]==-1:
      dist[e] = d + dd
      deq += [(e,d+dd)]
for i in range(Q):
  x, y = map(int, input().split())
  print(dist[x-1]+dist[y-1])

Measured memory_bytes: 90200
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/15/ALDS1_15_C

n = int(input())
lst = [list(map(int, input().split())) for _ in range(n)]
lst.sort(key=lambda x: x[1])
now = -1
ans = 0
for s, t in lst:
    if now < s:
        ans += 1
        now = t
print(ans)



Measured memory_bytes: 24368
#include<cstdio>
#include<algorithm>
 
using namespace std;
 
int main()
{
int N;
scanf("%d",&N);
int A,ret=9999999,tmp,w;
for(int i=0;i<N;i++)
{
scanf("%d",&A);
tmp=0;
w=1;
while(w)
{
if(A%2==0)
{
A=A/2;
tmp++;
}else{w=0;}
}
ret=min(tmp,ret);
}
printf("%d",ret);
return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
o = [[0] * 2 for i in range(n)]
acCount = 0
penalty = 0
for i in range(m):
    p, s = input().split()
    if o[int(p)-1][0] == 1:
        pass
    else:
        if s == 'AC':
            o[int(p)-1][0] = 1
        elif s == 'WA':
            o[int(p)-1][1] += 1

for j in range(n):
    if o[j][0] == 1:
        acCount += 1
        penalty += o[j][1]
    else:
        pass
# output
print(acCount, penalty)

Measured memory_bytes: 13172
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

int main()
{
    cin.tie(0);

    int h, w;
    cin >> h >> w;

    vector<string> bd(h);
    for (auto& row : bd)
        cin >> row;

    map<char, int> mm;

    for (auto& row : bd) {
        for (char& c : row) {
            mm[c]++;
        }
    }

    map<int, int> cc;
    for (int y = 0; y < (h + 1) / 2; y++) {
        for (int x = 0; x < (w + 1) / 2; x++) {
            bool oy = h % 2 == 1 && y == h / 2;
            bool ox = w % 2 == 1 && x == w / 2;

            int cnt = 4;
            if (oy)
                cnt /= 2;
            if (ox)
                cnt /= 2;

            cc[cnt]++;
        }
    }

    for (int tt = 0; tt < 3; tt++) {
        static int tbl[3] = { 4, 2, 1 };
        int t = tbl[tt];

        // cerr << t << ": " << cc[t] << endl;

        for (int i = 0; i < cc[t]; i++) {
            bool ok = false;
            for (auto& p : mm) {
                // cout << "* " << p.first << ", " << p.second << " - " << t << endl;
                if (p.second >= t) {
                    p.second -= t;
                    ok = true;
                    break;
                }
            }

            if (!ok) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())

mx = max(A)
mxidx = A.index(mx)

for i in range(N):
    if i == mxidx:
        B = A[0:i] + A[i+1:N]
        print(max(B))
    else:
        print(mx)

Measured memory_bytes: 19760
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;cin >>n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];

	int now =1;
	for(int i=0;i<n;i++)
	{
		if(a[i]==now)now++;
	}
	if(now==1)
	{
		cout<<-1<<endl;
		return 0;
	}
	now--;

	cout<<n-now<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ff first
#define ss second
#define maxn 1000000007
#define PI 3.14159265358979323846
#define MAX 1000007 
using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    //cout<<fixed<<setprecision(20);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=(c*d)/__gcd(c,d);
    ll tmp=(b/c)-(a/c);
    if(a%c==0)
    {
        tmp++;
    }
    ll tmp1=(b/d)-(a/d);
    if(a%d==0)
    {
        tmp1++;
    }
    ll tmp2=(b/x)-(a/x);
    if(a%x==0)
    {
        tmp2++;
    }
    ll tmp3=tmp+tmp1-tmp2;
    cout<<(b-a+1)-tmp3<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	string s, t; cin >> s;
	t = s.substr(4);
	cout << "2018" + t << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sy=sys.stdin.readline

n=int(sy())
if n==1:
    print(1)
    quit()
dp=[0]*(n+1)
lis=[0]*(2*10**5+1)
dp[0],dp[1],dp[2]=0,1,1
c1=int(sy())
c2=int(sy())
lis[c1]=1
lis[c2]=2
for i in range(3,n+1):
    c1=c2
    c2=int(sy())
    if c1==c2 or lis[c2]==0:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]+dp[lis[c2]]
    lis[c2]=i
    dp[i]%=1000000007
print(dp[n])

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

using namespace std;

int main()
{
    int K,A,B;
    int flag = 1;
    cin >> K >> A >> B;

    for(int i = A; i < B+1; i++){
        if(i % K == 0){
            cout << "OK";
            flag = 1;
            break;
        }
        else{
            flag = 0;
        }
    }
    if(flag == 0){
        cout << "NG";
    }


}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int N;
  cin >> N;
  int count = 0;
  rep(i,N){
    int a;
    cin >> a;
    if(i % 2 == 1){
      continue;
    }
    else{
      if(a % 2 == 1){
        count ++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

int main(){
    int d, g;
    cin >> d >> g;
    g /= 100;

    vector<pair<int, int>> score;
    for (auto i = 1; i <= d; i++) {
        int p, c;
        cin >> p >> c;
        score.emplace_back(make_pair(p, p * i + c / 100));
    }

    int min_count = INT_MAX;
    for (auto i = 0; i < (1 << score.size()); i++) {
        int count = 0, sum = 0, max_index = -1;
        for (auto j = 0; j < score.size(); j++) {
            if (i & (1 << j)) {
                count += score[j].first;
                sum += score[j].second;
            } else max_index = j;
        }
        if(sum < g) {
            if (max_index != -1) {
                int tmp = (g - sum + max_index) / (max_index + 1);
                if(score[max_index].first >= tmp) {
                    count += tmp;
                    min_count = min(min_count, count);
                }
            }
        } else min_count = min(min_count, count);
    }

    cout << min_count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char a[5],b[5];
  scanf("%s%s",a,b);
  if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=5005;
char s[N],t[N];
int qa[N],qb[N*3];
int main(){
	int n=read();
	scanf("%s%s",s+1,t+1); 
	for(int i=1;i<=n;i++){
		s[i]-='0'; t[i]-='0';
	}
	s[0]=s[n+1]=t[0]=t[n+1]=-1;
	*qa=1;
	for(int i=1;i<=n;i++){
		if(s[i]!=s[i+1])qa[++*qa]=i;
	}
	*qb=*qa+((s[1]!=t[1])^(*qa%2))+1;
	for(int i=1;i<=n;i++){
		if(t[i]!=t[i+1])qb[++*qb]=i;
	}
	for(int i=1;i<=*qa;i++)qb[++*qb]=n;
	int ans=1e9;
	//for(int i=1;i<=*qa;i++)cout<<qa[i]<<" "; puts("");
	//for(int i=1;i<=*qb;i++)cout<<qb[i]<<" "; puts("");
	for(int i=1;i+*qa-1<=*qb;i+=2){
		int sum=0; 
		for(int j=1;j<=*qa;j++)sum+=abs(qa[j]-qb[i+j-1]);
		for(int k=1;k<i;k++)sum+=qb[k];
		for(int k=*qa+i;k<=*qb;k++)sum+=n-qb[k];
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
const int N=100005;
using namespace std;
int n,to[N*2],hd[N*2],lk[N],cnt,
re[N],f[N],sz[N],de[N];
bool vis[N];
inline void add(int u,int v){
	to[++cnt]=v,hd[cnt]=lk[u],lk[u]=cnt;
}int u,v;
void dfs(int x){
	sz[x]=1;
	for(int s,i=lk[x];i;i=hd[i])
	if(f[x]^(s=to[i]))
	f[s]=x,de[s]=de[x]+1,dfs(s),
	sz[x]+=sz[s];
}
inline void get(int x){
	f[x]=0,dfs(x);
	for(int i=1;i<=n;i++)
	if(de[i]>de[u])u=i;
}
inline void cal(int s){
	for(int k=1;k<s;k++)
	printf("%d ",u+k);
	printf("%d ",u),u+=s;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	scanf("%d%d",&u,&v),
	add(u,v),add(v,u);
	get(1),get(u),v=cnt=0;
	for(;vis[u]=1,u;u=f[u])
	re[cnt++]=sz[u]-v,v=sz[u];
	for(int i=1;i<=n;i++)
	if(!vis[f[i]])return puts("-1"),0;
	u=1,v=2;
	for(int i=0,j=cnt-1;i<cnt;i++,j--){
		if(v>1&&re[i]!=re[j])
		v=re[i]<re[j];
		cal(re[v?i:j]);
	}
}

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


int main(){
    ll r,D,x;
    cin >> r >> D >> x;
    rep(i,10){
        x = r*x-D;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, x = map(int, readline().split())

v = a * a * b
s = x / a

if x == v:
    print(0)
    exit()

if x <= v / 2:
    # print(math.degrees(math.atan(2 * s / b / b)))
    print(90 - math.degrees(math.atan(2 * x / a / b / b)))
else:
    print(90 - math.degrees(math.atan(a / (b - (2 * s / a - b)))))



Measured memory_bytes: 38380
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector <int> f(N + 1, 0);
  
  for (int x = 1; x * x < N; ++x) {
    for (int y = 1; y * y < N; ++y) {
      for (int z = 1; z * z < N; ++z) {
        long a = x * x + y * y + z * z + x * y + y * z + z * x;
        if (a <= N) {
          f[a]++;
        }
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    cout << f[i] << endl;
  }
     
  return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n;
    cin >> n;
    long long m = 1e15;
    for(int i = 0;i<5;i++){
        long long ai;
        cin >> ai;
        if(m > ai){
            m = ai;
        }
    }
    long long a = 5;
    if(n % m != 0){
        a = (long long)n/m+5;
    }else{
        a = (long long)n/m+4;
    }
    cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
#define MX 1005 

int main(){	 


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin>>s;
    ll cnt=0;
    ll ans=0;
    ll f=0;
    ll n=s.length();
    for(int i=0;i<n;i++){
    	if(s[i]=='R'){
    		if(f==0){
    			cnt=1;
    			f=1;
    		}
    		if(i+1<n and s[i]==s[i+1])cnt++;
    		else{
    			ans=max(ans,cnt);
    			cnt=0;
    		}
    	} else{
    		ans=max(ans,cnt);
    		cnt=0;
    	}
    }
    cout<<max(ans,cnt);
	
	return 0;


}


Measured memory_bytes: 3616
n = int(input())
A = list(map(int, input().split()))
m = {}
ans = 0
for i in range(n):
    x = A[i] + i
    if x not in m:
        m[x] = 0
    m[x] += 1
    if i - A[i] in m:
        ans += m[i - A[i]]
print(ans)

Measured memory_bytes: 40508
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

result = 0
pre = -2

for i in range(n):
    result += b[a[i] -1]
    if a[i] == pre + 1:
        result += c[pre -1]
    pre = a[i]

print(result)

Measured memory_bytes: 38256
using System;
using System.Linq;

namespace AOJ0084
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine(String.Join(" ", (from w in Console.ReadLine().Split(new[] { ' ', '.', ',' },
                                                    StringSplitOptions.RemoveEmptyEntries)
                                                where w.Length >= 3 && w.Length <= 6
                                                select w).ToArray()));
        }
    }
}

Measured memory_bytes: 5644
#include <cstdio>
#include <set>
#include <vector>

int main()
{
  int s, t; //number of integers for S and T

  int count = 0; // number of integers of T in S
  
  std::set<int> S; // set S to be checked against

  scanf("%d", &s);
  
  for (int i = 0; i < s; ++i) {
    int input;
    scanf("%d", &input);
    S.insert(input);
  }

  scanf("%d", &t);

  std::vector<int> T (t, 0);

  for (int i = 0; i < t; ++i) {
    int input;
    scanf("%d", &input);
    T[i] = input;
  }

  for (int i = 0; i < t; ++i) {
    if ( S.count (T[i]) ) ++count; // increment count if found in S
  }

  printf("%d\n", count);
}
    

Measured memory_bytes: 2812
//void _(){
//    int n,m;
//    cin >> n >> m;
//    vpii order;
//    rep(i,0,n-1){
//        if(i%2)
//            rep(j,0,m-1)
//                order.pb({i,j});
//        else
//            for(int j = m-1; j >= 0; --j)
//                order.pb({i,j});
//    }
//    watch(order);
//    vvi ans(n,vi(m));
//    int k;
//    cin >> k;
//    vi s(k);
//    cin >> s;
//    reverse(all(s));
//    int col = 1;
//    for(auto _ : order){
//        ans[_.X][_.Y] = col;
//        if(--s.back() == 0){
//            s.pop_back();
//            ++col;
//        }
//    }
//    print(ans,"\n");
//}
#include <iomanip>
#include <algorithm>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define watch(x) cerr << (#x) << " = " << x << '\n'
#define X first
#define Y second
#define T1 template<typename T> static
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
template <typename F, typename S> static
ostream& operator<<(ostream& stream, const pair<F, S>& t){
    return stream << t.first << ' ' << t.second;
}
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
T1 ostream& print(T b, T e, string sep = " ", ostream& stream = cout){
    for(T it = b; it != e; ++it){
        stream << *it;
        if(it + 1 != e)
            stream << sep;
    }
    return stream;
}
T1 ostream& operator<<(ostream& stream, const vector<T>& t){
    return print(all(t), " ", stream);
}
T1 void print(vector<T> arr, string sep = " "){
    if(arr.empty()){
        return;
    }
    print(arr.begin(), arr.end(), sep);
    cout << '\n';
}
void _(){
    int n,m;
    cin >> n >> m;
    vpii order;
    rep(i,0,n-1){
        if(i%2)
            rep(j,0,m-1)
                order.pb({i,j});
        else
            for(int j = m-1; j >= 0; --j)
                order.pb({i,j});
    }
    watch(order);
    vvi ans(n,vi(m));
    int k;
    cin >> k;
    vi s(k);
    cin >> s;
    reverse(all(s));
    int col = 1;
    for(auto _ : order){
        ans[_.X][_.Y] = col;
        if(--s.back() == 0){
            s.pop_back();
            ++col;
        }
    }
    print(ans,"\n");
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        _();
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rip(a,b) for(int (a)=0;(a)<(b);(a)++)
using namespace std;

long long two(long long y){
    if(y==0){
        return 1;
    }
    return two(y-1)*2;
}

unsigned long long sum(unsigned long long x){
    unsigned long long result=0;
    for(unsigned long long i=0;i<x+1;i++){
        result+=two(i);
    }
    return result;
}


int main(){
    unsigned long long H;
    cin >> H;

    long long counter=0;
    while(H!=1){
    H=H/2;
    counter++;
    }
    // cout << counter << endl;
    cout << sum(counter) << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	
	printf("%d\n", (n + 1) / 2);
	return 0;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import Counter
    input = sys.stdin.readline

    N = int(input())
    S = input().rstrip('\n')

    C = Counter(S)
    ans = 1
    for x in C.values():
        ans = (ans * (x+1))%mod
    print(ans-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39408
n,m,d=map(int,input().split())
INF=10**18
c=[0]*n
a=[]
for i in range(n):
  c[i],*b=list(map(int,input().split()))
  a.append(b)
ans=INF
for i in range(2**n):
  x=[0]*m
  cnt=0
  for j in range(n):
    if (i>>j)&1:
      cnt+=c[j]
      for k in range(m):
        x[k]+=a[j][k]
  for j in range(m):
    if x[j]<d:break
  else:ans=min(cnt,ans)
print(ans if ans!=INF else -1)

Measured memory_bytes: 74084
N = int(input())
A = list(map(int,input().split()))

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a % b)

g = gcd(A[0],A[1])

for i in range(2,N):
    g = gcd(g,A[i])

print(g)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong h, w;
llong var[2005][2005];
llong hol[2005][2005];
char mp[2005][2005];

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mp[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            llong cnt = 0;
            while (j < w && mp[i][j] != '#') {
                cnt++;
                j++;
            }

            llong tmpj = j - 1;
            while (tmpj >= 0 && mp[i][tmpj] != '#') {
                hol[i][tmpj] = cnt;
                tmpj--;
            }
        }
    }
    
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            llong cnt = 0;
            while (j < h && mp[j][i] != '#') {
                cnt++;
                j++;
            }

            llong tmpj = j - 1;
            while (tmpj >= 0 && mp[tmpj][i] != '#') {
                var[tmpj][i] = cnt;
                tmpj--;
            }
        }
    }

    llong ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (mp[i][j] != '#') {
                ans = max(ans, var[i][j] + hol[i][j] - 1);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 66944
/*
ID: garvits2 
TASK: ride
LANG: C++14                 
*/
#include <bits/stdc++.h>

using namespace std;
int arr[100001];
int main(){
	int n;
	cin >> n;
	int ans=0;
	for(int i = 1; i < n; i++){
		ans+=(n-1)/i;
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 3620
open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inline flip f a b = f b a  

// memoization
let inline memo size f =
  let dp = Array.create size None
  let rec g x =
    match dp.[x] with
    | None ->
      let v = f g x
      dp.[x] <- Some v
      v
    | Some v -> v
  g

let inline memo2 size1 size2 f =
  let dp = Array2D.create size1 size2 None
  let rec g x y =
    match Array2D.get dp x y with
    | None ->
      let v = f g x y
      Array2D.set dp x y (Some v)
      v
    | Some v -> v
  g

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

let N, M = readInts() |> pair
let sc = [| for _ in 1..M -> readInts() |> pair |]

let keta s n = (n / (pown 10 (N-s))) % 10
let pred n = Array.forall (fun (s, c) -> (keta s n) = c) sc

let min = if N = 1 then 0 else pown 10 (N-1)

seq { min..((pown 10 N)-1) }
|> Seq.tryFind pred
|> Option.getOr -1
|> printfn "%d"


Measured memory_bytes: 14172
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d", &n);
	if (!(100 <= n && n <= 999))
	{
		return 0;
	}
	if ((n / 100 == 7) || ((n / 10) % 10 == 7) || (n % 10 == 7))
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    if(s == "Sunny") {
        cout << "Cloudy\n";
    }else if(s=="Cloudy") {
        cout << "Rainy\n";
    }else {
        cout << "Sunny\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  rep(i,N) cin >> m.at(i);
  sort(m.begin(), m.end());  
  int all = 0;
  rep(i,N) all += m[i];
  int L = X - all;
  int res = N + L / m[0];
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long X, long long N, std::vector<long long> p) {
  int cur = 1e5;
  int idx = -1;
  for (int i = -1000; i < 1000; i++) {
    bool flag = false;
    rep(j, N) if (p[j] == i) flag = true;
    if (!flag)
      if (abs(i - X) < cur) {
        cur = abs(i - X);
        idx = i;
      }
  }
  cout << idx << endl;
}

signed main() {
  long long X;
  scanf("%lld", &X);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> p(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &p[i]);
  }
  solve(X, N, std::move(p));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long
#define p pair<ll, int>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    ll a[n], b[n];
    vector<p> v;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        v.push_back(p(a[i], b[i]));
    }
    sort(v.begin(), v.end());
    ll sum = 0;
    int i = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        sum += v[i].first * v[i].second;
        cnt += v[i].second;
        if (cnt >= m) {
            sum -= (cnt - m) * v[i].first;
            break;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3444
import java.util.Scanner;

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


		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		int nums[] = new int[n];

//		Scanner sc2 = new Scanner(System.in);
		for (int i = 0; i < n; i++) {
			nums[i] = Integer.parseInt(sc.next());
		}
		int count = 0;

		while (true) {

			boolean flg = false;

			for (int i = 0; i < n; i++) {
				if (nums[i] % 2 == 0) {
					flg = true;
					nums[i] = nums[i]/2;
				} else {
					flg = false;
					break;
				}
			}

			if (flg) {
				count++;

				continue;
			} else {
				break;
			}
		}

		System.out.println(count);

	}
}


Measured memory_bytes: 22612
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}

void main()
{
  int n, m; readV(n, m);
  int[] a, b; readC(m, a, b);
  a[] -= 1; b[] -= 1;

  auto r = 0;
  foreach (i; 0..m) {
    auto uf = UnionFind!int(n);
    foreach (j; 0..m)
      if (i != j) uf.unite(a[j], b[j]);
    if (uf.countForests > 1) ++r;
  }

  writeln(r);
}

struct UnionFind(T)
{
  import std.algorithm, std.range;

  T[] p; // parent
  const T s; // sentinel
  const T n;
  T countForests; // number of forests
  T[] countNodes; // number of nodes in forests

  this(T n)
  {
    this.n = n;
    s = n;
    p = new T[](n);
    p[] = s;
    countForests = n;
    countNodes = new T[](n);
    countNodes[] = 1;
  }

  T opIndex(T i)
  {
    if (p[i] == s) {
      return i;
    } else {
      p[i] = this[p[i]];
      return p[i];
    }
  }

  bool unite(T i, T j)
  {
    auto pi = this[i], pj = this[j];
    if (pi != pj) {
      p[pj] = pi;
      --countForests;
      countNodes[pi] += countNodes[pj];
      return true;
    } else {
      return false;
    }
  }

  auto countNodesOf(T i) { return countNodes[this[i]]; }
  bool isSame(T i, T j) { return this[i] == this[j]; }

  auto groups()
  {
    auto g = new T[][](n);
    foreach (i; 0..n) g[this[i]] ~= i;
    return g.filter!(l => !l.empty);
  }
}


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

template<class T, class U>
bool contain(const std::basic_string<T>& s, const U& v)
{
	return s.find(v) != std::basic_string<T>::npos;
}
// int ans = contain(s, "AB");

int  main()
{

	int n; cin >> n;
	int cnt = 0;
	string s[n];
	queue<string> aq;
	queue<string> bq;
	string abq;
	string ab;
	string str;
	int k = 0 , b = 0, z = 0;
	rep(i, n)
	{
		cin >> s[i];
		if (s[i].front() == 'B' && s[i].back() == 'A')
		{
			abq += s[i];
			k++;
		}
		else if (s[i].front() == 'B')
		{
			bq.push(s[i]);
			b++;
		}
		else if (s[i].back() == 'A')
		{
			aq.push(s[i]);
			z++;
		}
		else
			str += s[i];
	}
	if (b == z)
	{
		if (!bq.empty() && !aq.empty())
		{
			abq = aq.front() += abq;
			abq += bq.front();
			aq.pop(); bq.pop();
		}
	}
	while (!aq.empty() && !bq.empty())
	{
		ab += (aq.front()+bq.front());
		aq.pop(); bq.pop();
	}
	if (!aq.empty())
	{
		while (!aq.empty())
		{
			abq = aq.front() += abq;
			aq.pop();
		}
	}
	if (!bq.empty())
	{
		while (!bq.empty())
		{
			abq += bq.front();
			bq.pop();
		}
	}
	string ans = abq + ab + str;
	rep(i, ans.size())
	{
		if (ans.substr(i, 2) == "AB")
			cnt++;
	}
	// cout << k << endl;
	// cout << b << endl;
	// cout << z << endl;
	cout << cnt << endl;
	return (0);
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int MAX = 20*200+1;

int LCS(string S, string T);

int main() {

    int n; cin >> n;
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        string s, t;
        cin >> s >> t;
        ans[i] = LCS(s, t);
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] << '\n';
    }

}

int LCS(string S, string T) {

    int row = S.size();
    int column = T.size();
    vector< vector<int> > dp(row, vector<int>(column, 0));

    for (int i = 0; i < row; i++) {
        if(S[i] == T[0]) {
            dp[i][0] = 1;
        }
        if (i > 0) {
            if (dp[i-1][0])
                dp[i][0] = 1;
        }
    }
    for (int i = 0; i < column; i++) {
        if(S[0] == T[i]) {
            dp[0][i] = 1;
        }
        if (i > 0) {
            if (dp[0][i-1])
                dp[0][i] = 1;
        }
    }

    for (int i = 1; i < row; i++) {
        for (int j = 1; j < column; j++) {
            if (S[i] == T[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    return dp[row-1][column-1];

}



Measured memory_bytes: 6708