akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

int main(){
  string s;
  cin >> s;
  string ret = "No";
 
  string c1, c2, temp;
  c1 = s.substr(0,1);
  for(int i=1; i<4; i++){
    temp = s.substr(i,1);
    if(c1!=temp){
      c2 = temp;
    }
  }

  int ct1=0;
  int ct2=0;
  for(int i=0; i<4; i++){
    temp = s.substr(i,1);
    if(c1==temp) ct1++;
    if(c2==temp) ct2++;
  }
  
  if(ct1==2&&ct2==2) ret = "Yes";
  
  cout << ret << endl;
  return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> ub(N), lb(N);
    int64_t ans = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        ub[i] = max(a, i);
        lb[i] = min(a, i);
        ans += abs(a-i);
    }
    sort(ub.begin(), ub.end());
    sort(lb.rbegin(), lb.rend());
    for(int i=0; i<M; i++) ans += 2 * max(0, lb[i] - ub[i]);
    cout << ans << endl;
}



Measured memory_bytes: 3608
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n; cin>>n;
    ll ans=0;
    rep(i,n){
        ans+=i+1;
    }
    cout<<ans<<endl;
}





























































































Measured memory_bytes: 3652
#include<stdio.h>
int main(){
  int n,i,count;
  int a[10000];
  scanf("%d",&n);
  count = 0;
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
    while(a[i] % 2 == 0) {
      a[i] /= 2; count++;
  }
  }
  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		
		int L[] = new int[N];
		L[0] = A[0];
		for(int i = 1; i < N; i++) {
			L[i] = gcd(L[i - 1], A[i]);
		}
		
		int R[] = new int[N];
		R[N - 1] = A[N - 1];
		for(int i = N - 2; i >= 0; i--) {
			R[i] = gcd(R[i + 1], A[i]);
		}
		
		int ans = Math.max(L[N - 1], Math.max(R[1], L[N - 2]));
		for(int i = 0; i < N - 2; i++) {
			ans = Math.max(ans, gcd(L[i], R[i + 2]));
		}
		System.out.println(ans);
	}
	
	static int gcd (int a, int b) {
		return b > 0 ? gcd(b, a % b) : a;
	}
}


Measured memory_bytes: 51844
#include<iostream>
#include<iomanip>
#include<cstring>
using std::cin;
using std::cout;
constexpr int max = 1000000;
int prime[1000010], tot = 0, n, a[1000010], cnt[1000010], flag[1000010];
bool isprime[1000010];

void getlist() {
    memset(isprime, true, sizeof(isprime));
    isprime[1] = false;
    for (int i = 2; i <= max; ++i) {
        if (isprime[i]) prime[++tot] = i;
        for (int j = 1; j <= tot && i * prime[j] <= max; ++j) {
            isprime[i * prime[j]] = false;
            if (i % prime[j] == 0) break;
        }
    }
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //cout << std::setiosflags(std::ios::fixed) << std::setprecision(3);
    getlist();
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        ++flag[a[i]];
    }
    int g = a[1];
    for (int i = 2; i <= n; ++i) g = gcd(g, a[i]);
    bool f = true;
    for (int i = 1; i <= tot; ++i) {
        for (int j = prime[i]; j <= max; j += prime[i]) cnt[prime[i]] += flag[j];
        if (cnt[prime[i]] > 1) {
            f = false;
            break;
        }
    }
    if (f) {
        cout << "pairwise coprime\n";
    }
    else if (!f && g == 1) {
        cout << "setwise coprime\n";
    }
    else cout << "not coprime\n";
    return 0;
}


Measured memory_bytes: 12992
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
        string s, t;
        cin >> s >> t;
        
        if (s == t.substr(0, s.size())) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
                
        return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MAX_D (200)
#define MAX_N (200)

int d, n;
int t[MAX_D];
int a[MAX_N], b[MAX_N], c[MAX_N];

int dp[MAX_D + 1][MAX_N];
// dp[ ?????\????????§??????????????? ][ ?????????????????? ] = ?´??????????????¨?

int search(int i, int last)
{
	int &res = dp[i][last];
	
	if (res != -1) return (res);
	
	if (i == d) return (res = 0);
	
	for (int j = 0; j < n; j++){
		if (t[i] < a[j] || b[j] < t[i]) continue;
		int sub = abs(c[last] - c[j]);
		res = max(res, sub + search(i + 1, j));
	}
	
	return (res);
}

int main()
{
	scanf("%d %d", &d, &n);
	for (int i = 0; i < d; i++){
		scanf("%d", &t[i]);
	}
	for (int i = 0; i < n; i++){
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
	}
	
	memset(dp, -1, sizeof(dp));
	
	int ans = 0;
	for (int i = 0; i < n; i++){
		if (t[0] < a[i] || b[i] < t[0]) continue;
		ans = max(ans, search(1, i));
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1368
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;

	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,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  vector<int> A(N);
  REP(i, N) A[i] = nextInt();
  ll ans = 0;
  REP(j, N) {
    REP(i, j) {
      ans += A[i] * A[j];
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main(){
  int n, a, b, c;

  cin >> n;

  for (int i=0; i<n; i++){
    cin >> a >> b >> c;
    if (a*a == b*b+c*c){
      cout << "YES" << endl;
    } else if (b*b == a*a+c*c){
      cout << "YES" << endl;
    } else if (c*c == a*a+b*b){
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int d;
	int i;
	int area;
	
	while (scanf("%d", &d) != EOF){
		area = 0;
		
		for (i = 1; i < 600 / d; i++){
			area += (i * d) * (i * d) * d;
		}
		
		printf("%d\n", area);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <bitset>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;

int main() {
  int n; cin>>n;
  int a[n+1]={};
  for(int i=0;i<n;i++) {int b; cin>>b; a[b]++;};
  ll an = 1;
  for(int i=(n+1)%2;i<=n;i+=2) {
    if (i==0) {
      if (a[i]!=1) an=0;
    } else {
      if (a[i]!=2) an=0;
      else an=an*2%M;
    }
  }
  cout<<an<<endl;
}
// Thank you for making problems and running the contest

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	Scanner scan = new Scanner(System.in);
	
	void compute() {
		int N = scan.nextInt();
		int m = 0;
		int n = 0;
		Integer[] t = new Integer[N];
		for(int i=0; i<N; i++) {
			t[i] = scan.nextInt();
			if(m < t[i]) {
				m = t[i];
				n = i;
			}
		}
		Arrays.sort(t, Collections.reverseOrder());
		for(int i=0; i<N; i++) {
			if(n != i) {
				System.out.println(m);
			} else {
				System.out.println(t[1]);
			}
		}
	}

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

}


Measured memory_bytes: 95316
/*
-----------------------------------------------------------------------------
Author :            ---------------------------------------------------------
    UTKAR$H $AXENA  ---------------------------------------------------------
    GOOGLE          ---------------------------------------------------------
-----------------------------------------------------------------------------
*/
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
#define fre freopen("0.in", "r", stdin), freopen("0.out", "w", stdout)
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007
#define LL signed long long int
#define ps(x) push_back(x)
#define scan(x) scanf("%d", &x)
#define print(x) printf("%d\n", x)
#define scanll(x) scanf("%lld", &x)
#define printll(x) printf("%lld\n", x)
#define boost ios_base::sync_with_stdio(0)
// vector<int> g[2*100000+5];int par[2*100000+5];
map<pair<LL, LL>, LL> g1, g2;
void getSet(map<pair<LL, LL>, LL> &g, string S) {
  int n = S.size();
  // cout << S << endl;
  LL p = 31;
  for (int mask = 0; mask < (1 << n); ++mask) {
    LL p1 = 1, p2 = 1;
    for (int i = 0; i < n; ++i) {
      if (mask & (1 << i)) {
        p1 = p1 * p + (S[i] - 'a');
        p1 %= MOD;
      } else {
        p2 = p2 * p + (S[i] - 'a');
        p2 %= MOD;
      }
    }
    g[{p1, p2}]++;
  }
}
int main() {
  // fre;
  int N;
  cin >> N;
  string S;
  cin >> S;
  getSet(g1, S.substr(0, N));
  string x = S.substr(N, N);
  reverse(x.begin(), x.end());
  getSet(g2, x);
  LL ans = 0;
  for (auto &p : g1) {
    if (g2.find(p.first) != g2.end()) {
      // cout << p.first.first << ' ' << p.first.second << ' ' << p.second <<
      // endl;
      ans += p.second * 1LL * g2[p.first];
    }
  }
  cout << ans;
}


Measured memory_bytes: 33024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
#include <stack>

using namespace std;

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

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

  int N;
  cin >> N;
  map<int, vector<Pii> > edge;
  for (int i = 0; i < N; i++) edge[i] = vector<Pii>();
  for (int i = 0; i < N-1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[a-1].push_back(Pii(b-1, c)); // zero index
    edge[b-1].push_back(Pii(a-1, c)); // zero index
  }
  int Q, K;
  cin >> Q >> K;
  K--; // zero index
  vector<Pii> query;
  for (int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    query.push_back(Pii(x-1, y-1)); // zero index
  }

  vector<ll> distFromK;
  vector<bool> visited;
  for (int i = 0; i < N; i++) {
    distFromK.push_back(0);
    visited.push_back(false);
  }
  stack<int> s;
  s.push(K);
  while (s.size() > 0) {
    int now = s.top();
    s.pop();
    for (auto& x : edge[now]) {
      if (!visited[x.first]) {
        distFromK[x.first] = distFromK[now] + x.second;
        s.push(x.first);
      }
    }
    visited[now] = true;
  }
  vector<ll> ans;
  for (int i = 0; i < Q; i++) {
    ans.push_back(distFromK[query[i].first] + distFromK[query[i].second]);
  }

  for (int i = 0; i < Q; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 16516
#include <iostream>

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


ll mod = 1000000000+7;

ll sol(ll tar_, ll kei_){
    ll s;
    if(kei_ == 0){return 1;}
    if(kei_ == 1){return tar_ % mod;}
    s = sol(tar_, kei_ / 2);
    if(kei_ % 2 == 0){
        return (s*s)%mod;
    }else{
        return (tar_*s%mod*s)%mod; 
    }
}


ll a[100005] = {};
P num_check[100005] = {};
ll kai[100005] = {};
ll un_kai[100005] = {};

ll C(int a_, int b_){
    if(a_ < 0 || b_ < 0 || a_ - b_ < 0) return 0;
    return kai[a_]*un_kai[b_]%mod*un_kai[a_-b_] % mod;
}

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

    

    int n;
    P da;

    cin >> n;
    for(int i = 1; i <= n+1; i++){
        cin >> a[i];    
        if(num_check[a[i]].first == 0)  {  num_check[a[i]].first = -1; num_check[a[i]].second = i;}
        else{da.first = i; da.second = num_check[a[i]].second;}
    }

    //map
    kai[0] = 1;
    un_kai[0] = 1;
    for(int i = 1; i < 100005; i++){
        kai[i] = (kai[i-1] * i) % mod;
        un_kai[i] = sol(kai[i], mod-2);
    }

    //cout << n << '\n';
    for(int i = 1; i <= n+1; i++){
        cout << (C(n+1, i) + mod - C(n+1-da.first+da.second-1, i-1))%mod << '\n';
    }


   return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	vecll b(m);
	rep(i, m) cin >> b[i];
	ll ans = 0;
	rep(i, n)
	{
		ll tmp_sum = 0;
		rep(j, m)
		{
			ll tmp;
			cin >> tmp;
			tmp_sum += tmp * b[j];
		}
		if (tmp_sum + c > 0)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
x = int(input())
base = 26
len = 1

while x > base:
    x -= base
    base = base * 26
    len += 1

ret = ""
subbase = base // 26
x -= 1
while subbase:
    c = x // subbase
    # print(f"x = {x}, c = {c}")
    ret += chr(ord("a") + c)
    x -= subbase * c
    subbase //= 26
    
print(ret)

Measured memory_bytes: 9184
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  int K, X;
  cin >> K >> X;

  if ((500 * K) >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  ll n;
  cin >> n;
  //l a, b, c,d,e;
  //cin >> a >> b >> c >> d;
  //string s; cin >> s;
  ll result = 1;
  bool judge = true;
  ll buf=1;
  for(i=2;i<=n;i++){
    for(buf=i*i;buf<=n;buf*=i){
      chmax(result,buf);
    }
  }
  cout << result << endl;
  /*
  vector<ll> a(n);
  for(i=0;i<n;i++)
    cin >> a[i];
  //for(i=0;<n;i++)
  */





  return 0;
}

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

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

int main(void){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = b-a+1;
	ans -= b/c - a/c;
	if(a%c==0) ans -= 1;
	ans -= b/d - a/d;
	if(a%d==0) ans -= 1;
	ll l = c / myGcd(c, d) * d;
	ans += b/l - a/l;
	if(a%l==0) ans += 1;
	cout <<  ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll a[32];
  a[0]=a[1]=a[2]=a[4]=a[6]=a[10]=a[12]=a[14]=a[16]=a[18]=a[22]=a[28]=a[30]=1;
  a[3]=a[5]=a[8]=a[9]=a[13]=a[20]=a[21]=a[24]=a[25]=2;
  a[7]=a[11]=a[17]=a[19]=a[26]=5;
  a[15]=14;
  a[23]=15;
  a[31]=51;
  a[27]=a[29]=4;
  ll n;
  cin>>n;
  cout<<a[n-1];
  
  
  
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int H,N,A;
  int sum;
  scanf("%d%d",&H,&N);
  sum=H;
  for(int i=0;i<N;i++){
    scanf("%d",&A);
    if(sum>=0){
        sum-=A;
      }
    }
 if(sum<=0){
  printf("Yes\n");
 }else{
  printf("No\n");
 }
  return 0;
}

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

int main() {
    ll N, X, Y;
    cin >> N >> X >> Y;
    vector<vector<ll>> G(N);
    rep(i, N-1){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[X-1].push_back(Y-1);
    G[Y-1].push_back(X-1);
    vector<ll> ans(N-1, 0);

    rep(i, N){
        vector<ll> dist(N, -1);
        queue<ll> que; 
        dist[i] = 0;
        que.push(i);
        while(!que.empty()){
            ll v = que.front();
            que.pop();
            for(ll nv : G[v]){
                if(dist[nv] != -1) continue;
                dist[nv] = dist[v] + 1;
                que.push(nv);
                ans[dist[nv]-1]++;
            }
        }
    }
    
    rep(i, N-1){
        cout << ans[i]/2 << endl;
    }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void update(int idx,vector<int>&bit,int val){
	
	while(idx<=500005){
		bit[idx]+=val;
		idx+=(idx&(-idx));
	}
	return ;
}

ll query(vector<int>&bit,int idx){
	ll s=0;
	while(idx>0){
	//	cout<<idx<<"  ";
		s+=bit[idx];
		idx-=(idx&(-idx));
	}//cout<<endl;
	return s;
}
void print(vector<int>&bit){
	
	for(int i=0;i<=10;i++)cout<<bit[i]<<" ";
	cout<<endl;
	return ;
}

int main(){
	io;
	ll n,t;
	cin>>n>>t;
	vector<ll>v(n+1);
	for(ll i=1;i<=n;i++){
		cin>>v[i];
	}
	
	vector<pair<ll,pair<ll,ll> > >q(t);
	for(ll i=0;i<t;i++){
		cin>>q[i].ss.ff>>q[i].ff;
		q[i].ss.ss=i;
	}
	
	sort(q.begin(),q.end());
	vector<int>ans(t);
	vector<int>bit(500009),last(500009,-1);
	int counter=0;
	
	for(ll i=1;i<=n;i++){
		if(last[v[i]]!=-1){
			update(last[v[i]],bit,-1);
		}last[v[i]]=i;
		update(last[v[i]],bit,1);
		//print(bit);
		while(counter<t && q[counter].ff==i){
			//ans[q[counter].ss.ss]
			ans[q[counter].ss.ss]=query(bit,i)-query(bit,q[counter].ss.ff-1);
			//cout<<val<<" "<<q[counter].ss.ss<<endl;
			counter++;
		}
	}
	
	for(int i=0;i<t;i++){
		cout<<ans[i]<<endl;
	}
	
	return 0;
}

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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "No";
  if((a+b) >= c) ans = "Yes";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

struct item{
    int w;
    int v;
};

using P = pair<lint, string>;

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

    int n, w;
    cin >> n >> w;
    vector<item> items(n);
    for(int i=0; i<n; i++){
        cin >> items[i].w >> items[i].v;
    }

    vector<vector<lint>> dp(w+1, vector<lint>(n+1, 0));

    for(int i=1; i<(int)dp.size(); i++){
        for(int j=1; j<(int)dp[i].size(); j++){
            if(items[j-1].w > i){
                dp[i][j] = dp[i][j-1];
                continue;
            }

            dp[i][j] = max(dp[i][j-1], dp[i-items[j-1].w][j-1] + items[j-1].v);
        }
    }

    COUT(dp.back().back());

    return 0;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,m,i,j;
	scanf("%d %d",&n,&m);
	int numpen = 0;
	int ac = 0;
	bool isAc[100001];
	memset(isAc, false, sizeof isAc);
	int pen[100001];
	memset(pen, 0, sizeof pen);
	for(i=0;i<m;i++){
		int soal;
		string stat;
		cin>>soal>>stat;
		if(isAc[soal]){continue;}
		if(stat == "WA"){
			pen[soal]++;
		}else{
			isAc[soal] = true;
			ac++;
		}
	}
	printf("%d ",ac);
	for(i=1;i<=n;i++){
		if(isAc[i]){
			numpen += pen[i];
		}
	}
	printf("%d\n",numpen);
	return 0;
};

Measured memory_bytes: 768
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int desc(const void* a, const void* b) {
	return *(ll*)b - *(ll*)a;
}

int main(void) {
	ll n;
	ll h[200000];
	cin >> n;
	for (ll i = 0; i < n; ++i) {
		cin >> h[i];
	}
	qsort(h, n, sizeof(*h), desc);
	for (ll i = 0; i < n-1; ++i) {
		if (h[i] == h[i + 1]) {
			cout << "NO";
          return 0;
		}
	}
	cout << "YES";
}


Measured memory_bytes: 3324
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

class UnionFind {
public:
  vector<int> _par;
  vector<int> _size;
  UnionFind(int sz_) : _par(sz_), _size(sz_, 1LL) {
    for (int i = 0; i < sz_; i++) _par[i] += i;
  }
  void init(int sz_) {
    _par.resize(sz_);
    _size.assign(sz_, 1LL);
    for (int i = 0; i < sz_; i++) _par[i] = i;
  }
  int root(int x) {
    while (_par[x] != x) {
      x = _par[x] = _par[_par[x]];
    }
    return x;
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (_size[x] < _size[y]) swap(x, y);
    _size[x] += _size[y];
    _par[y] = x;
    return true;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return _size[root(x)];
  }
};
const int MAX_E = 500000; //change if you need.
int V, E;                 //assign!!
struct edge {
  int u, v, cost;
};
edge es[MAX_E];
bool comp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; }
int kruskal() {
  sort(es, es + E, comp);
  UnionFind uf(V);
  int res = 0;
  for (int i = 0; i < E; i++) {
    edge e = es[i];
    if (!uf.same(e.u, e.v)) {
      uf.unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

signed main() {
  cin >> V >> E;
  int s, t, cost;
  rep(i, E) {
    cin >> s >> t >> cost;
    es[i] = {s, t, cost};
  }
  int res = kruskal();
  cout << res << endl;
}



Measured memory_bytes: 5596
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main{

    static class Edge{
        int to,cap,rev;
        Edge(int to,int cap,int rev){
            this.to=to;
            this.cap=cap;
            this.rev=rev;
        }
    }
    
    static List<Edge> G[];
    static void add_edge(int from,int to,int cap){
        G[from].add(new Edge(to,cap,G[to].size()));
        G[to].add(new Edge(from,0,G[from].size()-1));
    }

    static boolean used[]=new boolean[10000];
    static int dfs(int v,int t,int f){
        if(v==t)return f;
        used[v]=true;
        for(int i=0;i<G[v].size();++i){
            Edge e = G[v].get(i);
            if(!used[e.to]&&e.cap>0){
                int d = dfs(e.to,t,Math.min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    G[e.to].get(e.rev).cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }

    static int max_flow(int s,int t){
        int flow = 0;
        while(true){
            Arrays.fill(used,false);
            int f = dfs(s,t,100000);
            if(f==0)return flow;
            flow +=f;
        }
    }

    static class Point{
        int y,x;
        Point(int y,int x){
            this.y=y;
            this.x=x;
        }
    }
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        Point[] red = new Point[N];
        Point[] blue = new Point[N];
        G = new ArrayList[2*N+2];
        for(int i=0;i<=2*N+1;++i)G[i] = new ArrayList<>();
        for(int i=0;i<N;++i){
            int a = scan.nextInt();
            int b = scan.nextInt();
            red[i] = new Point(b,a);
        }
        for(int i=0;i<N;++i){
            int c = scan.nextInt();
            int d = scan.nextInt();
            blue[i] = new Point(d,c);
        }
        for(int i=0;i<N;++i){
            for(int j=0;j<N;++j){
                if(blue[i].y>red[j].y && blue[i].x>red[j].x)add_edge(i+1, N+j+1, 1);
            }
        }
        for(int i=0;i<N;++i)add_edge(0, i+1, 1);
        for(int i=N+1;i<=2*N;++i)add_edge(i, 2*N+1, 1);
        System.out.println(max_flow(0, 2*N+1));


    }
}

Measured memory_bytes: 22484
use std::io::Read;
const MOD: u64 = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<u64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut ans: u64 = 0;
    for bit in 0..60 {
        let mut cnt: u64 = 0;
        for i in 0..n {
            cnt += (a[i] >> bit) & 1;
        }
        ans = (ans + ((1u64 << bit) % MOD) * (cnt * (n as u64 - cnt) % MOD) % MOD) % MOD;
    }
    println!("{}", ans);
}

Measured memory_bytes: 13560
import sys
N, K = map(int, input().split())
S = input()

count = 0

if N == 1:
    print(0)
    sys.exit()
else:
    for n in range(1, N - 1):
        if S[n] == 'R':
            if S[n + 1] == S[n]:
                count += 1
        elif S[n] == 'L':
            if S[n - 1] == S[n]:
                count += 1

if S[0] == S[1] == 'R':
    count += 1
if S[N - 1] == S[N - 2] == 'L':
    count += 1

ans = min(count + K * 2, N - 1)
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  string u;
  cin >> s >> t >> u;
  int a = 0,b = 0,c = 0;
  int turn = 0;
  while(1){
    switch(turn){
      case 0:
        turn = s[a]-'a';
        a++;
        break;
      case 1:
        turn = t[b]-'a';
        b++;
        break;
      case 2:
        turn = u[c]-'a';
        c++;
        break;
      default:
      break;
    }
    if(a == s.sz+1 || b == t.sz+1 || c == u.sz+1)break;
  }
  if(a == s.sz+1)puts("A");
  else if(b == t.sz+1)puts("B");
  else puts("C");
  return 0;
}

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

const vector<pair<int, int>> DIFFs = {{1,0},{-1,0},{0,1},{0,-1}};
const int INF = 1e9;

int main() {
  int H, W;
  cin >> H >> W;

  int squeres[H][W];
  vector<pair<int, int>> blacks;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char A;
      cin >> A;
      
      if(A=='#') {
        blacks.push_back({i,j});
        squeres[i][j]=-1;
      } else {
        squeres[i][j]=INF;
      }
    }
  }

  queue<tuple<int, int, int>> q; //count, h, w;
  for (auto b: blacks) {
    int h = b.first;
    int w = b.second;
    q.push(make_tuple(0,h,w));
  }

  int ans = 0;
  while (!q.empty()) {
    int count, h, w;
    tie(count, h, w) = q.front();
    q.pop();
    if (squeres[h][w] < count && squeres[h][w]!=-1) continue;

    ans = max(ans, count);
    for(auto diff: DIFFs) {
      int dh = diff.first;
      int dw = diff.second;
      if ( 0<=h+dh && h+dh < H &&
           0<=w+dw && w+dw < W &&
           squeres[h+dh][w+dw] !=-1 &&
           squeres[h+dh][w+dw] > count+1 
           ) {
             squeres[h+dh][w+dw]=count+1;
             q.push(make_tuple(count+1, h+dh, w+dw));
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 24040
import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as BS8
import qualified Data.Vector as Vector
import Data.Vector ((!))

main :: IO ()
main = do
  [x, k, d] <- unfoldr (BS8.readInteger . BS8.dropWhile isSpace) <$> BS8.getLine

  let
    (n, m) = (abs x) `divMod` d
    o = minimum $ map abs [m - d, m + d]
    ans = abs $ if k >= n then
        if (k - n) `mod` 2 == 0 then m else o
      else minimum $ map abs [x + k * d, x - k * d]

  print ans


Measured memory_bytes: 3804
c=0
n=int(input())
l=list(map(int, input().split()))
for i in range(n-1):
    for j in range(n-1,i,-1):
        if l[j] < l[j-1]:
            t=l[j]
            l[j]=l[j-1]
            l[j-1]=t
            c+=1
print(*l)
print(c)

Measured memory_bytes: 7700
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define mod 998244353 
int32_t main()
{
 	int n,m;
 	cin>>n>>m;
 	int l[n],a[n+1];a[0]=0;
 	for(int  i=1;i<=n;i++)
 	{
 		cin>>l[i-1];
 		a[i]=a[i-1]+l[i-1];
 	}
 	int e=upper_bound(a,a+n+1,m)-a;
 	cout<<e;

}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
//ここから書き始める

int main()
{
	cout <<setprecision(10);
	int n;
	cin >>n ;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	int four = 0, two = 0;
	rep(i,n){
		if(v[i] % 4 == 0){
			four ++;
		}
		else if(v[i] % 2 ==0){
			two ++;
		}
	}
	if(two > 0){
		n -= two;
		if(four > 0){
			n++;
		}
	}
	ll pos = four * 2;
	if(four >= 1){
		pos++;
	}
//	debug(n);
//	debug(pos);
	if(pos >= n){
		coY();
	}else {
		coN();
	}
}


Measured memory_bytes: 1024
n=int(input())
a=[]
for i in range(n):
    x,y=input().split()
    y=int(y)
    if x == "S":
        a.append(y+0)
    if x == "H":
        a.append(y+13)
    if x == "C":
        a.append(y+26)
    if x == "D":
        a.append(y+39)
for i in range(1,53):
        if not(i in a):
            if i<=13:
                print("S {}".format(i - 0))
            elif i<=26:
                print("H {}".format(i - 13))
            elif i<=39:
                print("C {}".format(i - 26))
            else:
                print("D {}".format(i - 39))


Measured memory_bytes: 5596
using System;
using System.Collections.Generic;
namespace std
{
    class Test
    {
        static void Main(string[] args)
        {
            int i = 0;

            List<int> ary = new List<int>();
  
            while(true) {
                var input  = int.Parse(Console.ReadLine()); 
              if(input == 0) break;
                ary.Add(input);
              //  if(ary[i]== 0) break;
                i++;
            }
  
           for (i = 0; i < ary.Count; i++) {
                Console.WriteLine("Case {0}: {1}", i+1, ary[i]);
           }
            
        }
    }
}


Measured memory_bytes: 15920
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	h = readline() |> split |> parseMap
	k = 1
	for i in 2:n
		flg = 0
		for j in 1:i-1
			if h[i]<h[j]
				flg = 1
				break
			end
		end
		if flg == 0
			k += 1
		end
	end
	println(k)
end
main()


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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> v(26, 114514);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        vector<int> now(26);
        for (auto c:s)now[c - 'a']++;
        for (int j = 0; j < 26; j++)v[j] = min(v[j], now[j]);
    }

    for (int i = 0; i < 26; i++)cout << string(v[i], 'a' + i);
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main() {
	int N, A, B;
	cin >> N >> A >> B;

	int b = 1;
	int c = 0;
	int sum = 0;

	for (int i = 1; i <= N; i++) {
		b = i;
		c = i;
		int a = 0;
		while (b > 0) {
			a += b % 10;
			b /= 10;
		}
		if (a >= A && a <= B) {
			sum += c;
		}
	}

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int flag=0;
        while(n--)
        {
            int x;
            scanf("%d",&x);
            if(x%2==1) {flag=1;}
        }
        printf("%s\n",flag?"first":"second");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int A,B;
  cin >> A >> B;
  cout << (A-1)*(B-1) << endl;
  return 0;
}

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

using namespace std;

int p[200005], siz[200005];

int find(int s) {
	if (s == p[s]) return s;
	return p[s] = find(p[s]);
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	
	for (int i = 1; i <= n; i++) {
		p[i] = i;
		siz[i] = 1;
	}
	
	int res = 1;
	
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		
		int u = find(x);
		int v = find(y);
		
		if (u != v) {
			p[u] = v;
			siz[v] += siz[u];
			res = max(res, siz[v]);
		}
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 5388
// AOJ 0574: Nails
// 2017.11.1 bal4u@uu

#include <stdio.h>
#include <string.h>

int tbl[5002][5002];

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
    int n, m, x, y, r, ans;

    fgets(p=buf, 30, stdin);
	n = getint(), p++, m = getint();
	memset(tbl, 0, sizeof(tbl));
	while (m--) {
		fgets(p=buf, 30, stdin);
		y = getint()-1, p++, x = getint()-1, p++, r = getint();
		tbl[y][x]++, tbl[y][x+1]--;
		tbl[y+r+1][x]--, tbl[y+r+2][x+1]++;
		tbl[y+r+1][x+r+2]++, tbl[y+r+2][x+r+2]--;
	}

	for (y = 0; y < n; y++) for (x = 0; x <= y; x++) tbl[y  ][x+1] += tbl[y][x];
	for (y = 0; y < n; y++) for (x = 0; x <= y; x++) tbl[y+1][x  ] += tbl[y][x];
	for (y = 0; y < n; y++) for (x = 0; x <= y; x++) tbl[y+1][x+1] += tbl[y][x];
	ans = 0;
	for (y = 0; y < n; y++) for (x = 0; x <= y; x++) if (tbl[y][x] > 0) ans++;
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 99500
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int H, W, t[20][20];
int dy[] = {0, 1}, dx[] = {1,0}; // 横　縦

int judge(int y, int x){
  map<int, int>m;
  for(int i = -1; i < 1; i++){
    for(int j = -1; j < 1; j++){
      int ny = y+i, nx = x+j;
      if(ny < 0 || nx < 0 || t[ny][nx] == -1 || m.count(t[ny][nx])) continue;
      m[t[ny][nx]] = 1;
    }
  }
  //  printf("size %d\n", (int)m.size());
  if(m.size() < 4) return 1;
  return 0;
}

int dfs(int n){
  //  fprintf(stderr, "\n%d\n", n);
  int i, j, res = 0;
  for(i = 0; i < H; i++) for(j = 0; j < W; j++) if(t[i][j] == -1) goto b;
 b:

  if(i == H && j == W) return 1;

  int tmp[20][20];
  rep(i, 20) rep(j, 20) tmp[i][j] = t[i][j];

  t[i][j] = n;
  //  printf("i %d j %d\n", i, j); 
  rep(d, 2){
    int x = j+dx[d], y = i+dy[d];
    //    fprintf(stderr, "%d %d\n", y, x);
    if(x < 0 || x >= W || y < 0 || y >= H || t[y][x] != -1) continue;
    t[y][x] = n;
    if(judge(i, j)) res += dfs(n+1);
    t[y][x] = -1;
  }
  rep(i, 20) rep(j, 20) t[i][j] = tmp[i][j];

  return res;
}

int main(){
  while(scanf("%d%d", &H, &W) && H+W){
    memset(t, -1, sizeof(t));
    printf("%d\n", dfs(0));
  }
  return 0;
}

Measured memory_bytes: 1520
#include <stdio.h>
#define N 100000

typedef struct process{
    char name[100];
    int t;
    int next;
    int prev;
} process_t;

    process_t proc[N];

int main(void) {
    int i;
    int n, q;
    int total; 
    int pnt;
    int cnt;

    scanf("%d", &n);
    scanf("%d", &q);

    for(i=0; i<n; i++){
        proc[i].next = i+1;
        proc[i].prev = i-1;
        scanf("%s", proc[i].name);
        scanf("%d", &proc[i].t);
    }

    proc[n-1].next = 0;
    proc[0].prev = n-1;

    total = 0;
    pnt = 0;
    cnt = n;

    while(cnt > 0){
        if(proc[pnt].t > q) {
            proc[pnt].t -= q;
            total += q;
            pnt = proc[pnt].next;
        }
        
        else {
            total += proc[pnt].t;
            printf("%s %d\n", proc[pnt].name, total);
            proc[proc[pnt].prev].next = proc[pnt].next;
            proc[proc[pnt].next].prev = proc[pnt].prev;
            pnt = proc[pnt].next;
            cnt--;            
        }
    }

    return 0;
}


Measured memory_bytes: 7248
#x:配列
mod=10**9+7
def multarray(x):
    ret=1
    for i in x:
        ret*=i
        ret%=mod
    return ret

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

#n==kの場合はかけるだけ
if n==k:
    print(multarray(a))
    exit()

#0以上の数と負の数に分けて格納
ap,am=[],[]
for i in range(n):
    if a[i]>=0:
        ap.append(a[i])
    else:
        am.append(a[i])
#それぞれ絶対値の順番にソート
ap.sort(reverse=True)
am.sort()

#0以上の数のみか正の数のみの場合は先に場合分け
if len(am)==0:
    print(multarray(ap[:k]))
    exit()
if len(ap)==0:
    if k%2==0:
        print(multarray(am[:k]))
    else:
        print(multarray(am[::-1][:k]))
    exit()

#組にして格納する(0以上か負かを記録しておく)
apm2=[]
for i in range(len(am)//2):
    apm2.append((am[2*i]*am[2*i+1],0))
for i in range(len(ap)//2):
    apm2.append((ap[2*i]*ap[2*i+1],1))
apm2.sort(reverse=True)

#0以上の数で次にどこを見るのかをチェックしておく
p=0
ans=[]
for i in range(k//2):
    p+=(2*apm2[i][1])
    ans.append(apm2[i][0])

#Kが偶数の時
if k%2==0:
    print(multarray(ans))
    exit()

ans_cand=[]
#一個増やす場合
if p!=len(ap):
    ans_cand.append(multarray(ans)*ap[p]%mod)
#一個減らして二個増やす場合
if p!=0:
    #減らすindex
    check_i=ans.index(ap[p-1]*ap[p-2])
    #ap[p-1]を減らす操作(0除算を避ける)
    ans[check_i]=ap[p-2]
    ans.append(apm2[k//2][0])
    ans_cand.append(multarray(ans))
print(max(ans_cand))


Measured memory_bytes: 33092
#include <iostream>
using namespace std;
int main(void){
    long long N,i,a,s;
    cin>>N;
    long long A[N];
    for(i=0;i<N;i++){
        cin>>A[i];
    }
    a=0;s=1;
    for(i=0;i<N;i++){
        a+=A[i]*s;
        s*=-1;
    }
    for(i=0;i<N;i++){
        cout<<a<<" ";
        a=A[i]*2-a;
    }
    cout<<endl;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e6 + 123;        	
const ld pi = 3.1741592653589793238462643;
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

ll n, k, a[N], dp[N];

main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);

//	srand(time(NULL));

	scanf("%d%d", &n, &k);

	for(ll i = 1; i <= n; i++) {
		scanf("%d", &a[i]);

		if(i == 1) continue;

		dp[i] = INF;
		for(ll j = i - 1; j >= max(1ll, i - k); j--)
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
	}

	cout << dp[n];
             
    return 0;                                        
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;
  
  vector<int> ans;
  int cnt = 0;
  for(int i=0;i<n;i++){
    if(A[i] != 1 && A[i] != 0 && A[i] != -1) ans.push_back(i);
    if(A[i] == -2) cnt++;
  }
  

  if(cnt%2 == 1){
    for(int i=0;i<n;i++){
      if(A[i] == -1) {ans.push_back(i),cnt--;break;}
    }
  }

  if(cnt%2 == 1){
    int m = ans.size();
    for(int i=0;i<(int)ans.size();i++) 
      if(A[ans[m-1-i]] == -2) {ans.erase(ans.begin()+m-1-i);cnt--;break;}
  }

  sort(ans.begin(),ans.end());
  assert(cnt % 2 == 0);

  cout<<ans.size()<<endl;
  for(int i=0;i<(int)ans.size();i++){
    cout<<ans[i]+1<<endl;
  }

  return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>

using namespace std;

void func(int N, int K, string source) {
    source[K - 1] += 32;
    cout << source << endl;
}

int main() {
    int N,K;
    string source;
    cin >> N >> K >> source;
    func(N,K,source);
//    func(3, 1, "ABC");
    return 0;
}


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

int gcd(int data01, int data02)     //get GCD
{
    int retData;
    if(data01 == data02)
    {
        retData = data01;
    }
    else if(data01 > data02)
    {
        retData = gcd(data01 - data02, data02);
    }
    else
    {
        retData = gcd(data02, data01);
    }
    return retData;
}

int main(void)
{
	int x, y= 0;                      //gcd = Greatest Common Divisor
	cin >> x >> y;                   //input Data

	cout << gcd(x, y) << endl;        //result
	return 0;
}

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

#define pb push_back
#define ff first
#define ss second

using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int a, b; cin >> a >> b;
    b *= 2;
    if (a - b > 0) cout << a-b;
    else cout << 0;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let s : String = get_one();
    let c : char = s.chars().nth(0).unwrap();
    println!("{}", if c == 'a' || c == 'e'  || c == 'i'  || c == 'o'  || c == 'u'  { "vowel" } else { "consonant" });
}


Measured memory_bytes: 4352