akhauriyash/Code-Regression huggingface dataset:
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    #table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime
n=10**5+2
a=sieve(n)
ans=[0]*(n//2)
for i in range(0,n,2):
    if a[i] and a[i//2]:
        ans[i//2]=1
#print(ans[:20])
for i in range(1,n//2):
    ans[i]+=ans[i-1]
#print(ans[:20])
q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    if l==1:
        l=2
    if r==1:
        r=2
    print(ans[r//2]-ans[l//2 -1])

Measured memory_bytes: 6108
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}

int main(void){
	int x=in(),y=in(),i,ans;
	ans=x+y;
	for(i=2;i<2*x;i+=2){
		if((y*i)%(2*x)==0){
			ans--;
		}
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 1836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int k, s;
    sc(k) sc(s)
    int ans = 0;
    for (int i = 0; i <= k; i++){
        for (int j = 0; j <= k; j++){
            if (s - i - j > k || s - i - j < 0) continue;
            ans += 1;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
a,b,c=map(int, input().split())
if a*b==0:
    if c-a-b<0:
        print("No")
    else:
        if 4*a*b < (c-a-b)**2:
            print("Yes")
        else:
            print("No")
else:
    if c-a-b<=0:
        print("No")
    else:
        if 4*a*b<(c-a-b)**2:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 61900
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


signed main()
{
	speed
	int n,k;cin>>n>>k;
	std::vector<int> inp(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>inp[i];
	}
	sort(inp.begin(),inp.end(),greater<int>());
	int ans=0;
	for(int i=k;i<n;++i)
	{
		ans+=inp[i];
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	long long a, b, c;
  	cin >> a >> b >> c;
  	long long d = c - a - b;
  	if (d>0 && d*d>4*a*b) cout << "Yes" << endl;
 	else cout << "No" << endl;
	return 0;
}

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

int  main()
{
	string s; cin >> s;
	if (s[0] == s[1] == s[2])
		cout << s << endl;
	else
	{
		if (stoi(s) <= 111)
			cout << 111;
		else if (stoi(s) <= 222)
			cout << 222;
		else if (stoi(s) <= 333)
			cout << 333;
		else if (stoi(s) <= 444)
			cout << 444;
		else if (stoi(s) <= 555)
			cout << 555;
		else if (stoi(s) <= 666)
			cout << 666;
		else if (stoi(s) <= 777)
			cout << 777;
		else if (stoi(s) <= 888)
			cout << 888;
		else if (stoi(s) <= 999)
			cout << 999;
	}
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;
/* テンプレートここまで */

int main() {
  ll N; cin >> N;
  ll t = 1;
  ll a = 1;
  REP(i, N){
    ll T, A; cin >> T >> A;
    ll j = max((t+T-1)/T, (a+A-1)/A);
    t = j * T;
    a = j * A;
  }
  cout << (ll)(t+a) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,nowx=0,nowy=0,nowt=0;

int main(){
    cin>>N;
    int t[N],x[N],y[N];
    rep(i,N)cin>>t[i]>>x[i]>>y[i];
    rep(i,N){
        if((t[i]-nowt)>=(abs(nowx-x[i])+abs(nowy-y[i]))&&(t[i]-nowt-abs(nowx-x[i])-abs(nowy-y[i]))%2==0){
            nowx=x[i];
            nowy=y[i];
            nowt=t[i];
        }
        else{
            out("No");
            return 0;
        }
    }
    out("Yes");
}


Measured memory_bytes: 1408
import math

def main():
    x = int(input())
    ans = 0
    ans1 = math.floor(x / 1.08)
    ans2 = math.ceil(x / 1.08)
    if math.floor(ans1 * 1.08) == x:
        print(ans1)
        return
    elif math.floor(ans2 * 1.08) == x:
        print(ans2)
        return
    else:
        print(":(")

main()

Measured memory_bytes: 3060
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const ll inf=1e18;

int n, m;

char tab[2][nax];

char *raz;
char *dwa;

ll wyn=inf;

unordered_map <ll,char> mapa;

void proba(ll d)
{
	mapa.clear();
	for (int i=1; i<=n; i++)
		mapa[(i-1)*(d/n)+1]=raz[i];
	for (int i=1; i<=m; i++)
	{
		ll x=(i-1)*(d/m)+1;
		if (mapa.count(x) && mapa[x]!=dwa[i])
			return;
	}
	wyn=min(wyn, d);
}

int main()
{
	scanf("%d%d", &n, &m);
	scanf("%s", tab[0]+1);
	scanf("%s", tab[1]+1);
	raz=tab[0];
	dwa=tab[1];
	for (int h=1; h<=n; h++)
	{
		if (!(n%h))
		{
			proba((ll)n*m/h);
		}
	}
	
	if (wyn==inf)
		wyn=-1;
	printf("%lld\n", wyn);
	return 0;
}


Measured memory_bytes: 4260
#include<stdio.h>
#include <string.h>
int main(void)
{
	char str[1001];
	int i,j;

	scanf("%[^\n]",str);
	for(i=0; i<strlen(str); i++){
	  if(strncmp(&str[i],"apple",5) == 0)
	    strncpy(&str[i],"peach",5);
	  else if(strncmp(&str[i],"peach",5)==0)
	    strncpy(&str[i],"apple",5);
	}
	printf("%s\n",str);

	return 0;
}

Measured memory_bytes: 524
import sys
S = input()
N = len(S)
con = int((N-1)/2)  # 真ん中(0～のindex)

# 3文字の時
if N == 3:
    if S[0] == S[2]:
        print('Yes')
    else:
        print('No')
    sys.exit()

# conが偶数の時は前にある個数(con2,con3)も偶数
if con % 2 == 0:
    con20 = int(con/2-1)
    con21 = con20+1
    con30 = int(N-(N+3)/4)
    con31 = con30+1
    while con21 < con:
        if S[con20] != S[con21] or S[con20] != S[con31] or S[con21] != S[con30]:
            print('No')
            sys.exit()
        con20 = con20-1
        con21 = con21+1
        con30 = con30-1
        con31 = con31+1

# conが奇数の時は前にある個数(con2,con3)も奇数
else:
    con25 = int((con-1)/2)
    con35 = N-con25-1
    if S[con25] != S[con35]:
        print('No')
        sys.exit()
    con20 = con25-1
    con21 = con25+1
    con30 = con35-1
    con31 = con35+1
    while con21 < con:
        if S[con20] != S[con21] or S[con20] != S[con31] or S[con21] != S[con30]:
            print('No')
            sys.exit()
        con20 = con20-1
        con21 = con21+1
        con30 = con30-1
        con31 = con31+1

print('Yes')


Measured memory_bytes: 9176
import java.util.Scanner;

class Main {
    public static void main(String args[]){
	Scanner sc = new Scanner(System.in);

	int a,b,t,sum;
	a = sc.nextInt();
	b = sc.nextInt();
	t = sc.nextInt();

	sum = (t/a) * b;
	System.out.println(sum);
    }
}

	
	


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int count =3;
  if(a==b)count--;
  if(a==c)count--;
  if(b==c)count--;
  if(a==b&&b==c)count++;
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	if(a == 1)
	{
		a = 14;
	}
	if(b == 1)
	{
		b = 14;
	}
	if(a > b)
	{
		cout << "Alice" << endl;
		return 0;
	}
	else if(a == b)
	{
		cout << "Draw" << endl;
		return 0;
	}
	else
	{
		cout << "Bob" << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, x, ans=0;
	cin >> n >> x;
	vector<lli> a(n);
	rep(i,n) cin >> a[i];
	loop(i, 1, n){
		lli sum = a[i]+a[i-1];
		lli dist = sum - x;
		if(dist > 0){
			ans += dist;
			if(a[i] >= dist){
				a[i] -= dist;
			}else{
				a[i-1] -= (dist - a[i]);
				a[i] = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,k;cin >>n >> k;
    int ret = 1e18;
    rep(mask,1<<n){
        int tmp = 1;
        rep(i,n){
            if(mask >> i &1)tmp *= 2;
            else tmp += k;
        }
        ret = min(ret,tmp);
    }
    cout <<ret << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.HashMap;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		HashMap <Integer,Integer>hm = new HashMap<Integer,Integer>();
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n ; i++) {
			int a = sc.nextInt();
			if(!hm.containsKey(a)) {
				hm.put(a, 1);
			}
			else {
				hm.remove(a);
			}
		}
		System.out.println(hm.size());

	}

}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(N), B(M);
  
  string s;
  for(int i = 0; i < N; i++){
    cin >> s;
    for(int j = 0; j < N; j++){
      if(s[j] == '.'){
        A[i].push_back(0);
      }else{
        A[i].push_back(1);
      }
    }
  }

  for(int i = 0; i < M; i++){
    cin >> s;
    for(int j = 0; j < M; j++){
      if(s[j] == '.'){
        B[i].push_back(0);
      }else{
        B[i].push_back(1);
      }
    }
  }

  bool ok = false;
  for(int i = 0; i < N-M+1; i++){
    for(int j = 0; j < N-M+1; j++){
      bool tmp_ok = true;
      for(int x = 0; x < M; x++){
        for(int y = 0; y < M; y++){
          if(A[i+x][j+y] != B[x][y]){
            tmp_ok = false;
          }
        }
      }
      if(tmp_ok){
        ok = true;
        break;
      }            
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

int calc(int n, int k) {
    int aida = n - 1;
    return max(aida - k + 1, 0);
}

int main(int argc, char const* argv[])
{
    int N, X, Y;
    cin >> N >> X >> Y;

    X--;
    Y--;
    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            // int k = min(j - i,
            //             min(abs(X - i) + 1 + abs(j - Y),
            //                 abs(Y - i) + 1 + abs(j - X)));
            int k = min(j - i, abs(X - i) + 1 + abs(j - Y));
            mp[k]++;
        }
    }

    for (int k = 1; k < N; k++) {
        cout << mp[k] << endl;
    }
    return 0;
}

Measured memory_bytes: 384
# ABC123 D-Cake123

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A, reverse=True)[:K+1]
B = sorted(B, reverse=True)[:K+1]
C = sorted(C, reverse=True)[:K+1]

res = []

for i in A:
    for j in B:
        res.append(i + j)
res2 = []
res = sorted(res, reverse=True)[:K+1]

for i in C:
    for re in res:
        res2.append(i + re)

res2 = sorted(res2, reverse=True)[:K+1]

for i in range(K):
    print(res2[i])

Measured memory_bytes: 141152
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define int long long
using namespace std;
using P = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;

int H, W;
char a[100][100];
bool b[100], c[100];

void solve() {
  REP (i, H) {
    REP (j, W) {
      if (a[i][j] == '#') {
        b[i] = true;
        c[j] = true;
      }
    }
  }
  REP (i, H) {
    if (!b[i]) { continue; }
    REP (j, W) {
      if (!c[j]) { continue; }
      cout << a[i][j];
    }
    cout << endl;
  }
}

signed main() {
  cin >> H >> W;
  REP (i, H) {
    REP (j, W) {
      cin >> a[i][j];
    }
  }
  solve();
}


Measured memory_bytes: 256
N = int(input())
M = 10**9 + 7

if N < 3:
    print(0)
elif N < 6:
    print(1)
else:
    dp = [0] * (N + 1)
    dp[3] = 1
    dp[4] = 1
    dp[5] = 1
    P = dp[3]
    for i in range(6, N + 1):
        dp[i] = (P + 1) % M
        P = (P + dp[i - 2]) % M
    print(dp[-1] % M)

Measured memory_bytes: 63636
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    CNT = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        if a < b:
            CNT += (b-a+1)// 2
    sa = sum(A)
    sb = sum(B)
    if sa > sb:
        print('No')
    elif sb - sa >= CNT:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10456
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;

int main() {
    abdelrahman010
    int x;
    cin >> x;
    bool yes = false;
    while(!yes) {
        bool yes1 = true;
        for(int i = 2;1ll * i * i <= x;i++)
            if(x % i == 0) {
                yes1 = false;
                break;
            }
        yes = yes1 , x++;
    }
    cout << --x;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%d",a)
using namespace std;
int n;
char hh1[10][10],hh2[10][10];
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	scanf("%s",hh1);
	scanf("%s",hh2);
	//cout<<hh2[0][0];
	if (hh1[0][0]==hh2[0][2]&&hh1[0][1]==hh2[0][1]&&
	hh1[0][2]==hh2[0][0]) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 256
labels = input().split()
q = int(input())
dices = [[1, 3, 4, 2], 
         [0, 2, 5, 3], 
         [0, 4, 5, 1], 
         [0, 1, 5, 4], 
         [0, 3, 5, 2], 
         [1, 2, 4, 3]]

for i in range(q):
    n = [labels.index(s) for s in input().split()]
    b = (dices[n[1]].index(n[0]) + 1) % 4
    a = dices[n[1]][b]
    print(labels[a])


Measured memory_bytes: 5600
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n;
    scanf("%d", &n);
    int c[n], s[n], f[n];
    rep(i, 1, n){
        scanf("%d %d %d", &c[i], &s[i], &f[i]);
    }
    rep(i, 1, n){
        int ans = s[i] + c[i];
        rep(j, i+1, n){
            int buf = s[j];
            while(buf < ans){
                buf += f[j];
            }
            ans += (buf - ans) + c[j];
        }
        printf("%d\n", ans);
    }
    printf("0");

    return 0;
}

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

int main()
{
  int n,x;
  cin >> n >> x;
  
  int l[n];
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }
  
  int ans = 1;
  int total = 0;
  for(int i = 0; i < n; i++){
    total += l[i];
    if(total <= x){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 111
int n;
void solve(int n) {
        if (!n)
                return;
        int rem = n % 10;
        solve(n / 10);
        if (rem == 1) {
                printf("9");
        } else
                printf("1");
        return;
}
int main() {
        cin >> n;
        solve(n);
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;


int main(void) {
	int i, a, b;
	int pointSet[101];
	bool flag;

	flag = true;
	memset(pointSet, 0, sizeof(pointSet));
	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			for (i = 3; i < 101; i++) {
				if (pointSet[i] % 2 == 1) {
					flag = false;
					break;
				}
			}
			if (pointSet[1] % 2 == 1 && pointSet[2] % 2 == 1 && flag) {
				cout << "OK" << endl;
			}
			else {
				cout << "NG" << endl;
			}
			flag = true;
			memset(pointSet, 0, sizeof(pointSet));
		}
		else {
			pointSet[a]++;
			pointSet[b]++;
		}
	}

	return 0;
}




Measured memory_bytes: 3080
/* http://arc062.contest.atcoder.jp/tasks/arc062_a
 */
#include<bits/stdc++.h>
using namespace std;

int N;
void solve(){
	cin>>N;
	long long lastA = 1, lastB = 1;
	double lastRatio = 1.0;
	for (int i=0;i<N;i++){
		long long a,b;
		cin>>a>>b;
		double ratio = double(a)/b;
		long long divisor;
		if (ratio<lastRatio){
			divisor = (lastA-1)/a+1;
		}
		else{
			divisor = (lastB-1)/b+1;
		}
		lastA = (divisor)*a;
		lastB = divisor*b;
		lastRatio = ratio;
	}
	cout<<lastA+lastB<<'\n';
}
int main(){
//	freopen("in.txt","r",stdin);
	std::ios::sync_with_stdio(false);

	solve();
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
using vi = vector<int>;
using vll = vector<ll>;
ll fast_exp(ll base,ll e){
    ll r=1;
    while(e>0){
        if(e%2)r=(r*base);
        base=base*base;
        e/=2;
    }
    return r;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,W;cin>>n>>W;
    vll w(n),v(n);
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    vector<vll> dp(n+1,vll(W+1,0));
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(i>0&&j>0){
                if(w[i-1]<=j){
                    dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
                }
                else dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
    
}

Measured memory_bytes: 80256
<?php
fscanf(STDIN, "%s", $s);
for($i = 0; $i < strlen($s); $i++){
    if($i % 2 == 0 && $s[$i] == 'L'){
        echo "No";
        exit;
    }else if($i % 2 == 1 && $s[$i] == 'R'){
        echo "No";
        exit;
    }
}
echo "Yes";

Measured memory_bytes: 4604
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
int n;
int dp[1010];
void solve() {
    ll x;
    cin >> x;
    ll left = 1, right = x;
    while(left < right) {
        ll mid = (left + right + 1) / 2;
        if(mid * (mid + 1) / 2 <= x) {
            left = mid;
        } else right = mid - 1;
    }
    if(left * (left + 1) / 2 == x) {
        for (int i = 1; i <= left; i++) {
            cout << i << endl;
        }
        return;
    }
    ll t = left + 1 - (x - (left + 1) * left / 2);
    for (int i = 1; i <= left + 1; i++) {
        if(i == t) continue;
        cout << i << endl;
    }
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int k,i;
  string s;
  cin >> k >> s;
  if(s.size()<=k){
    cout << s << endl;
  }else{
    for(i=0;i<k;i++){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
}

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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=2e5+100,inf=1e18,LOG=23,mod=1e9+7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll

int n, a[maxn], ans = -1e18, pref[maxn][3], suff[maxn][3];

main()
{
	IOS
	cin >> n;
	forn(1, i, n)
	{
		cin >> a[i];
	}
	for(int i = 2; i <= n; i += 2)
	{
		pref[i][0] = pref[i - 2][0] + a[i - 1];
		pref[i][1] = max(pref[i - 2][0], pref[i - 2][1]) + a[i];
	}
	for(int i = n - 1; i >= 1; i -= 2)
	{
		suff[i][1] = suff[i + 2][1] + a[i + 1];
		suff[i][0] = max(suff[i + 2][1], suff[i + 2][0]) + a[i];
	}
	if(n % 2 == 0)
	{
		cout << max(pref[n][1], pref[n][0]);
	}
	else
	{
		for(int i = 1; i <= n; i += 2)
		{
			ans = max(max(pref[i - 1][0], pref[i - 1][1]) + max(suff[i + 1][1], suff[i + 1][0]), ans);
		}
		cout << ans;
	}
}

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

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

    int A, B, X;
    cin >> A >> B >> X;

    if(A > X || A + B < X) {
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
     
    int main(void){
    int H,W,i,j;
    char hoge[50];
    bool array[52][52]={0};
    scanf("%d",&H);
    scanf("%d",&W);
     
    for(i=0;i<H;i++){
    scanf("%s",&hoge);
    for(j=0;j<W;j++){
    if(hoge[j] == '#')array[i][j]=1;
    }
    }
     
    for(i=0;i<H;i++){
    for(j=0;j<W;j++){
    if(array[i][j]){
    if(array[i][j-1]
     ||array[i-1][j]                            ||array[i+1][j]
     ||array[i][j+1]){
    }else{
    printf("No");
    return 0;
    }
    }
    }
    }
    printf("Yes");
    return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

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

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll k, t, ans;
	in(k);
	in(t);

	vll a(t);
	rep(i, 0, t) {
		in(a[i]);
	}

	sort(a.begin(), a.end(), greater<ll>());
	ans = 2*(a[0] - (k % 2 == 0 ? k / 2 : k / 2 + 1))-1;

	if (ans < 0) {
		ans = 0;
	}
	outn(ans);
	return 0;

}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
A.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if A[i]+A[j]>A[k]:
        if A[i]!=A[j] and A[j]!=A[k]:
          ans+=1
      else:
        break
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define int ll
#define INF (1LL<<60)
#define mod 1000000007
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };


signed main(){
	int N, A, B;
	cin >> N >> A >> B;
	cout << ((B - A) % 2 == 1 ? "Borys" : "Alice") << endl;

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 17:11:49 2019

@author: Yamazaki Kenichi
"""

m = int(input())
A = [list(input().split()) for i in range(m)]

T = [[-1,-1,-1,-1]]
def insert(T,u,x):
    if T[0][3] == -1:
        T[0][3] = x
        return
    if x < T[u][3]:
        if T[u][1] == -1:
            T[u][1] = len(T)
            T.append([u,-1,-1,x])
        else:
            insert(T,T[u][1],x)
    else:
        if T[u][2] == -1:
            T[u][2] = len(T)
            T.append([u,-1,-1,x])
        else:
            insert(T,T[u][2],x)
def ino(u):
    if T[u][1] != -1:
        ino(T[u][1])
    ino_res.append(str(T[u][3]))
    if T[u][2] != -1:
        ino(T[u][2])
def pre(u):
    pre_res.append(str(T[u][3]))
    if T[u][1] != -1:
        pre(T[u][1])
    if T[u][2] != -1:
        pre(T[u][2])
def find(u,x):
    if x == T[u][3]:
        return True
    elif x < T[u][3]:
        if T[u][1] == -1:
            return False
        return find(T[u][1],x)
    else:
        if T[u][2] == -1:
            return False
        return find(T[u][2],x)
for c in A:
    if c[0] == 'insert':
        insert(T,0,int(c[1]))
    elif c[0] == 'find':
        print('yes') if find(0,int(c[1])) else print('no')
    else:
        ino_res = []
        ino(0)
        pre_res = []
        pre(0)
        print(' '+' '.join(ino_res))
        print(' '+' '.join(pre_res))
    


Measured memory_bytes: 248652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int v[] = new int[n + 1];
		int c[] = new int[n + 1];
int ans=0;
		for(int i=1;i<=n;i++){
		v[i]=sc.nextInt();
		}
		for(int i=1;i<=n;i++){
		c[i]=sc.nextInt();

		if(v[i]>=c[i]){
		ans=ans+v[i]-c[i];
		}}
System.out.println(ans);
	}}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main() 
{
	ll n,i; cin>>n;
	string s; map<string,ll>mp;
	mp["AC"]=0;
	mp["TLE"]=0;
	mp["RE"]=0;
	mp["WA"]=0;
	for(i=0;i<n;i++) 
	cin>>s , mp[s]++;
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
int main()
{
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    ll now = 100;
    int ans = 0;
    for (int i = 1 ; i <= 3760 ; i++){
        now = now + now * 0.01;
        if (now >= x) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int x;
    cin >> x;
    
    // calculation
    for (int i = x; i >= 1; --i) {
        if ((int)pow((int)sqrt(i), 2) == i) {
            cout << i << "\n";
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int n,nn,n1,i,a,count=0;
    scanf("%lld",&n);
    n1=n+1;
    nn=(n*n1)/2;
    for(i=1; i<=n; i++)
    {
        if(i%3==0 || i%5==0 || i%15==0)
            count=count+i;
    }
    printf("%lld\n",nn-count);
    return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
struct UnionFind {
    vector<int> data;

    UnionFind(int sz) { data.assign(sz, -1); }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y)
            return (false);
        if(data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if(data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }
    bool isSame(int x, int y) { return find(x) == find(y); }
    ll size(int k) { return (-data[find(k)]); }
};
int main() {
    int n;
    cin >> n;
    vector<pair<ll, int>> x(n), y(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i].first >> y[i].first;
        x[i].second = i;
        y[i].second = i;
    }
    sort(all(x));
    sort(all(y));
    priority_queue<pair<ll, pair<int, int>>> edge;
    for(int i = 1; i < n; i++) {
        edge.push(make_pair(x[i - 1].first - x[i].first,
                            make_pair(x[i].second, x[i - 1].second)));
    }
    for(int i = 1; i < n; i++) {
        edge.push(make_pair(y[i - 1].first - y[i].first,
                            make_pair(y[i].second, y[i - 1].second)));
    }
    UnionFind uf(n);
    ll w = 0;
    while(!edge.empty()) {
        auto e = edge.top();
        edge.pop();
        if(!uf.isSame(e.second.first, e.second.second)) {
            uf.unite(e.second.first, e.second.second);
            w -= e.first;
        }
    }
    cout << w << endl;
}


Measured memory_bytes: 9584
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define all(v) v.begin(), v.end()
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a / (b + c))*b + min(a-(a / (b + c))*(b + c), b) << endl;
}

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

int N;
int t[110000], x[110000], y[110000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    
    bool can = true;
    
    for (int i = 0; i < N; i++) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist)
            can = false;
        
        if (dist % 2 != dt %2)
            can = false;
        
    }
    if (can)
        cout << "Yes\n";
    else
        cout << "No\n";
    
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> r(n);
  for (int i = 1; i < n; i++) {
    int e;
    cin >> e;
    r[e - 1]++;
  }
  for (auto e : r) cout << e << endl;
}


Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;


int main(){
  long long N,b;
  cin >> N;
  vector<long long > city(N+1);


  for(long long i =0; i <N+1; ++i){
    cin >> city[i];
  }

  long  ans =0;
  for(long long i =0; i <N; ++i){
    cin >> b;
    long t = min(b,city[i] + city[i+1]);
    ans += t;
    city[i+1] -= t - min(b,city[i]);
  }  
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  long long int A, B, K;
  cin >> A >> B >> K;
  long long int tmp=min(A, K);
  A-=tmp;
  K-=tmp;
  tmp=min(B, K);
  B-=tmp;
  K-=tmp;
  cout << A << " " << B << endl;
  return 0;
}
 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int w,h;
  int i,j;
  int c[55][55];
  int ans;
  int v[55][55];
  int si,sj;
  int x,y;
  for(;;)
  {
    scanf("%d %d",&w,&h);
    if(h==0 && w==0)
      break;
    for(i=0;i<h;i++)
      for(j=0;j<w;j++)
        scanf("%d",&c[i][j]);
    ans=0;
    for(i=0;i<h;i++)
      for(j=0;j<w;j++)
        v[i][j]=0;
    
    for(;;)
    {
      si=sj=-1;
      for(i=0;i<h;i++)
      {
        for(j=0;j<w;j++)
        {
          if(v[i][j]==0 && c[i][j]==1)
          {
            si=i;
            sj=j;
            break;
          }
        }
        if(si>-1)
          break;
      }
      if(si==-1)
      {
        printf("%d\n",ans);
        break;
      }
      ans++;
      v[si][sj]=ans;
      for(x=0;x<h*w;x++)
      {
        y=0;
        for(i=0;i<h;i++)
        {
          for(j=0;j<w;j++)
          {
            if(c[i][j]==1 && v[i][j]==ans)
            {
              if(i>0 && j>0)
              {
                if(c[i-1][j-1]==1 && v[i-1][j-1]==0)
                {
                  v[i-1][j-1]=ans;
                  y++;
                }
              }
              if(i>0)
              {
                if(c[i-1][j]==1 && v[i-1][j]==0)
                {
                  v[i-1][j]=ans;
                  y++;
                }
              }
              if(i>0 && j<w-1)
              {
                if(c[i-1][j+1]==1 && v[i-1][j+1]==0)
                {
                  v[i-1][j+1]=ans;
                  y++;
                }
              }
              if(j>0)
              {
                if(c[i][j-1]==1 && v[i][j-1]==0)
                {
                  v[i][j-1]=ans;
                  y++;
                }
              }
              if(j<w-1)
              {
                if(c[i][j+1]==1 && v[i][j+1]==0)
                {
                  v[i][j+1]=ans;
                  y++;
                }
              }
              if(i<h-1 && j>0)
              {
                if(c[i+1][j-1]==1 && v[i+1][j-1]==0)
                {
                  v[i+1][j-1]=ans;
                  y++;
                }
              }
              if(i<h-1)
              {
                if(c[i+1][j]==1 && v[i+1][j]==0)
                {
                  v[i+1][j]=ans;
                  y++;
                }
              }
              if(i<h-1 && j<w-1)
              {
                if(c[i+1][j+1]==1 && v[i+1][j+1]==0)
                {
                  v[i+1][j+1]=ans;
                  y++;
                }
              }
            }
          }
        }
        if(y==0)
          break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2036
#include "bits/stdc++.h"
using namespace std;
vector<int> b;
vector<vector<int> > a;
int main()
{
    int n,m,c;
    int i,j;
    int sum,ans=0;
    scanf("%d %d %d",&n,&m,&c);
    c*=-1;
    a.resize(n+1);
    a[0].resize(m+1);
    b.resize(m+1);
    for(i=1;i<=m;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=1;i<=n;i++)
    {
        a[i].resize(m+1);
        sum=0;
        for(j=1;j<=m;j++)
        {
            scanf("%d",&a[i][j]);
            sum+=a[i][j]*b[j];
        }
        if(sum>c)
        {
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
} 

Measured memory_bytes: 256
from functools import lru_cache

N, A = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(lambda i: i - A, x))
X = max(max(x), A)

@lru_cache(maxsize=None)
def solve(j, t):
    global y
    if j == 0 and t == 0:
        return 1
    elif j >= 1 and (t < y[j - 1] - N * X or t > y[j - 1] + N * X):
        return solve(j - 1, t)
    elif j >= 1 and t >= y[j - 1] - N * X and t <= y[j - 1] + N * X:
        return solve(j - 1, t) + solve(j - 1, t - y[j - 1])
    else:
        return 0

print(solve(N, 0) - 1)


Measured memory_bytes: 7656
using System;

namespace ABC141A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            switch (S)
            {
                case "Sunny":
                    Console.WriteLine("Cloudy");
                    break;
                case "Cloudy":
                    Console.WriteLine("Rainy");
                    break;
                case "Rainy":
                    Console.WriteLine("Sunny");
                    break;
                default:
                    break;
            }
        }
    }
}

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

const int kNmax = 110;
const int kInf = numeric_limits<int>::max();

int n, a[kNmax];
int source, sink, flow[kNmax][kNmax], cap[kNmax][kNmax], father[kNmax];
vector<int> g[kNmax];
bool used[kNmax];

bool bfs() {
  for (int i = source; i <= sink; i++) {
    used[i] = false;
    father[i] = -1;
  }
  
  queue<int> q;
  q.push(source);
  used[source] = true;
  
  while (!q.empty()) {
    int node = q.front();
    q.pop();
    used[node] = true;
    if (node == sink) {
      break;
    }
    
    for (int vec : g[node]) {
      if (!used[vec] && cap[node][vec] > flow[node][vec]) {
        father[vec] = node;
        q.push(vec);
      }
    }
  }
  return used[sink];
}

long long maxFlow() {
  long long flowRes = 0;
  while (bfs()) {
    for (int vec: g[sink]) {
      if (used[vec] && cap[vec][sink] != flow[vec][sink]) {
        father[sink] = vec;
        int minFlow = kInf;
        for (int node = sink; node != source; node = father[node]) {
          minFlow = min(minFlow, cap[father[node]][node] - flow[father[node]][node]);
        }
        for (int node = sink; node != source; node = father[node]) {
          flow[father[node]][node] += minFlow;
          flow[node][father[node]] -= minFlow;
        }
        flowRes += minFlow;
      }
    }
  }
  return flowRes;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  
  source = 0;
  sink = n + 1;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] > 0) {
      sum += a[i];
      g[i].push_back(sink);
      g[sink].push_back(i);
      cap[i][sink] = a[i];
    } else if (a[i] < 0) {
      g[source].push_back(i);
      g[i].push_back(source);
      cap[source][i] = -a[i];
    }
  }
  
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      g[i].push_back(j);
      g[j].push_back(i);
      cap[i][j] = kInf;
    }
  }
  
  printf("%lld\n", sum - maxFlow());
  
  return 0;
}

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

#define llt long long int
llt fact(int n){
	llt ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
	}
	return ans;
}
int main() {
	// your code goes here
	int d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d){
		cout<<"Yes"<<endl;
	}
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  vector<ll> val;
  val.push_back(0);
  ll n;
  cin>>n;
  ll sum=0;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    sum+=a;
    val.push_back(val[i]+a);
  }
  ll ans=17441744174417;
  for(int i=0;i<=n;i++){
    ans=min(ans,abs(val[i]*2-sum));
  }
  cout<<ans<<endl;
}


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

#define sz(A) (int)(A.size())
using ll = long long;
ll H[1 << 20];
int n;
ll C;
ll dp[1 << 20];

using line = pair<ll,ll>;

deque<line> dq;

auto f = [](const line & l,const ll & x) {
	return l.first*x + l.second;
};

double g(line a,line b) {
	// a.first * x + a.second < b.first * x.bsecond
	// a.second - b.second)/b.first - b.second < x
	return (a.second - b.second)/(b.first - a.first + 0.0);
}

ll query(ll x) {
	while(dq.size() > 1 && f(dq[0],x) >= f(dq[1],x)) dq.pop_front();
	return f(dq[0],x);
}

void insert(ll a,ll b) {
	line nw(a,b);
	while(sz(dq) > 1 && g(dq[sz(dq)-2],nw) <= g(dq.back(),nw)) dq.pop_back();
	dq.push_back(nw);
}

int main(int argc,char **argv) {
	scanf("%d %lld",&n,&C);
	for(int i = 0;i < n;i++) scanf("%lld",H + i);

	insert(H[0],H[0]*H[0]);
	for(int j = 1;j < n;j++) {
		ll offset = H[j]*H[j] + C;
		ll x = -2*H[j];

		dp[j] = query(x) + offset;
		// cout << dp[j] << endl;

		insert(H[j],dp[j] + H[j]*H[j]);
	}

	cout << dp[n-1] << endl;
	return 0;
}

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


int main(){
	int N, D, X;
	cin >> N >> D >> X;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	int ans = N;
	rep(i,N){
		ans += (D-1)/A[i];
	}
	ans += X;
	cout << ans << endl;	
			
}












Measured memory_bytes: 3564
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var r, g, b int
	con.Scan(&r, &g, &b)
	i := r*100 + g*10 + b
	if i%4 == 0 {
		con.Println("YES")
	} else {
		con.Println("NO")
	}
	return nil
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string table[] = {"dream","dreamer","erase","eraser"};
	string s;
	cin >> s;
	
	reverse(s.begin(),s.end());
	for(int i=0;i<4;i++)	reverse(table[i].begin(),table[i].end());
	
	for(int i=0;i<(int)s.size();) {
		int j;
		for(j=0;j<4;j++) {
			int sz = (int)table[j].size();
			if(i + sz - 1 < (int)s.size() && s.substr(i,sz) == table[j])
				break;
		}
		if(j == 4) {
			cout << "NO" << endl;
			return 0;
		}
		i += (int)table[j].size();
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 512