akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
 
int main(){
  int S,W;
  if(scanf("%d%d",&S,&W) < 2) {
    fprintf(stderr, "error: ill-formed fraction.\n");
    exit(1);
  }
  
  if(S > W){
    printf("safe");
  } else {
    printf("unsafe");
  }
  return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i, n;
    double f = 1;
    
    scanf("%d", &n);
    if (1 <= n && n <= 20) {
        for (i = 1; i <= n; i++) {
            f *= i;
        }
        printf("%.0f\n", f);
    }
    
    return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int i;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5])
  {
    cout<<"Yes";
  }
  else
  {
    cout<<"No";
  }
  return 0;
}

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

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod=1e9+7;

ll res[100005];
int main()  {
    fast;
    ll n,w;    cin>>n>>w;
    ll a,b;
    fl(i,0,n)   {
        cin>>a>>b;
        for(int j=w;j>=a;j--)   res[j]=max(res[j],res[j-a]+b);
    }
    cout<<res[w];
}

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

int main(){
	double v, t, h;
	int ans;
	while(cin >> v){
		t = v / 9.8;
		h = 4.9 * t * t;
		for(int i=1; i<100000;i++){
			if(h < 5*i -5){
				ans = i;
				break;
			}
		}
		cout << ans <<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<stdio.h> 
int main(void) 
{  
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a>b) printf("a > b\n");
	else if(a<b) printf("a < b\n");
	if(a==b) printf("a == b\n");
	
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int N, M;
vector<vec> G;
int dp[100005];

int rec(int v){
    if(dp[v] != -1) return dp[v]; // 既に更新済み

    int res=0;
    for(auto nv: G[v]){
        res = max(res, rec(nv)+1);
    }

    return dp[v] = res; // メモしながらreturn
}

void solve() {
    cin >> N >> M;
    G.resize(N);

    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }

    memset(dp, -1, sizeof(dp));
    int res = 0;
    rep(i, N) res = max(res, rec(i));

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 12288
import sys
import fractions as f
n,m=map(int,input().split())
A=list(map(int,input().split()))
a=A[0]
b=0
while a%2==0:
  a=a//2
  b=b+1
b=2**b
B=[0]*n
for i in range(n):
  B[i]=A[i]//b
  if B[i]*b!=A[i] or B[i]%2==0:
    print(0)
    sys.exit()
G=1
for i in range(n):
  G=G*B[i]//(f.gcd(G,B[i]))
print(int((m+G*b//2))//(G*b))

Measured memory_bytes: 16280
#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>;
//#########################################
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int root(int x) {
      if (d[x] < 0) return x;
      return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
      x = root(x); y = root(y);
      if (x == y) return false;
      if (d[x] > d[y]) swap(x,y);
      d[x] += d[y];
      d[y] = x;
      return true;
    }
    bool same(int x, int y) { return root(x) == root(y);}
    int size(int x) { return -d[root(x)];}
  };
signed main(){
    int n,m;cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int a,b,c;cin >> a >> b >>c;
        a--;b--;
        uf.unite(a,b);
    }
    vector<int> vis(n);
    int ans = 0;
    rep(i,n){
        int p = uf.root(i);
        if(vis[p])continue;
        vis[p] = 1;
        ans++;
    }
    cout <<ans << endl;
    return 0;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A;
  cin >> A;
  int Y, M;
  Y = A / 100;
  M = A % 100;
  int YM, MY;
  YM = MY = 0;
  if(1 <= M && M <= 12) {
    YM++;
  }
  if(1 <= Y && Y <= 12) {
    MY++;
  }
  if(YM == 1 && MY == 0) {
    cout << "YYMM" << endl;
  }
  else if(MY == 1 && YM == 0) {
    cout << "MMYY" << endl;
  }
  else if(MY == 0 && YM == 0) {
    cout << "NA" << endl;
  }
  else {
    cout << "AMBIGUOUS" << endl;
  }
}

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

Measured memory_bytes: 256
#include <stdio.h>

#define LIMIT 1000000007
typedef long long LL;

LL summax(LL k, LL max);
LL summin(LL k){
    //0~k-1の和
    
    LL ans = ((k-1)*k);
    ans /= 2;
    //printf("summin(%lld) = %lld\n", k, ans);
    
    //オーバーフローするので~k-1, k項の和と考えると
    //LL ans = summax(k, k-1);
    //オーバーフローした
    //初項0なので、~k-1, k-1項の和と考えると
    //LL ans = summax(k-1, k-1);
    //同様にオーバーフローした
    /*LL ans = 0;
    for(int i=0; i<=k-1; i++){
        ans += i;
    }
    printf("summin(%lld) = %lld\n", k, ans);
    */
    return ans;
}

LL summax(LL k, LL max){
    //~max,k項の和
    LL ans = 2*max;
    ans = (ans-k+1);
    ans = ans*k;
    ans /= 2;
  	//%LIMITを消した
    //printf("summax(%lld, %lld) = %lld\n", k, max, ans);
    return ans;
}

int main(){
    LL N, K, k;
    scanf("%lld%lld", &N, &K);
    LL ans = 0, buf;
    for(k=K; k<=N+1; k++){
        buf = summax(k, N) - summin(k) + 1;
        //buf %= LIMIT;
        ans += buf;
        ans %= LIMIT;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define N 100000
char str[N];
int main(){
	cin>>str;
	int len=strlen(str);
	for(int i=0;i<len;i++){
		if((i+1)%2!=0){
			cout<<str[i];
		}
	}
	cout<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// ここから開始
int main(){
  string s;
  cin>>s;
  stack<char> stk;
  stk.push('T');
  for(int i = 0; i < s.length(); i++){
    // cout<<"Y"<<endl;
    if(s[i]=='S'){
      stk.push(s[i]);
    }
    else if(s[i]=='T'){
      if(stk.top()=='S'){
        stk.pop();
      }
      else{
        stk.push(s[i]);
      }
    }
  }
  cout<<stk.size()-1<<endl;
  return 0;
}



Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
char a[30];
int n,lenc;
char c[10004];
int main()
{
	for(int i=0;i<26;i++)
	{
		a[i]=i+65;
	}
	cin>>n;
	cin>>c;
	lenc=strlen(c);
	for(int i=0;i<lenc;i++)
	{
		cout<<a[(c[i]-65+n)%26];
	}
	cout<<endl;
	return 0;
} 

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

struct Tree{
 struct Node{ int l=-1,r=-1,p=-1; int v; };
 vector<Node> V;
 int R=-1;

 int& parentchild(int v){
  if(v==R) return R;
  if(V[V[v].p].l==v) return V[V[v].p].l;
  else return V[V[v].p].r;
 }
 void swapidx(int a,int b){
  swap(parentchild(a), parentchild(b));
  swap(V[a], V[b]);
  if (V[a].l != -1) V[V[a].l].p = a;
  if (V[a].r != -1) V[V[a].r].p = a;
  if (V[b].l != -1) V[V[b].l].p = b;
  if (V[b].r != -1) V[V[b].r].p = b;
 }
 void rotL(int v){
  int w=V[v].r;
  parentchild(v)=w; V[w].p=V[v].p;
  V[v].r=V[w].l; if(V[v].r!=-1) V[V[v].r].p=v;
  V[v].p=w; V[w].l=v;
 }
 void rotR(int v){
  int w=V[v].l;
  parentchild(v)=w; V[w].p=V[v].p;
  V[v].l=V[w].r; if(V[v].l!=-1) V[V[v].l].p=v;
  V[v].p=w; V[w].r=v;
 }

 void insert(int v){
  int p=-1; int* pp=&R;
  while(*pp!=-1){
   p=*pp;
   if(v<V[p].v) pp=&V[p].l;
   else pp=&V[p].r;
  }
  *pp=V.size();
  V.push_back({-1,-1,p,v});
 }
 int find(int v){
  int p=R;
  while(p!=-1){
   if(v==V[p].v) return p;
   if(v<V[p].v) p=V[p].l; else p=V[p].r;
  }
  return -1;
 }
 void erase(int v){
  if(V[v].l!=-1 && V[v].r!=-1){
   UL w=V[v].r;
   while(V[w].l!=-1) w=V[w].l;
   swap(V[v].v,V[w].v); v=w;
  }
  while(V[v].r!=-1){
   rotL(v);
  }
  while(V[v].l!=-1){
   rotR(v);
  }
  swapidx(v,V.size()-1);
  parentchild(V.size()-1)=-1;
  V.pop_back();
 }

 void printPreorder(int p=-2){
  if(p==-2) p=R;
  if(p==-1) return;
  printf(" %d",V[p].v);
  printPreorder(V[p].l);
  printPreorder(V[p].r);
 }
 void printInorder(int p=-2){
  if(p==-2) p=R;
  if(p==-1) return;
  printInorder(V[p].l);
  printf(" %d",V[p].v);
  printInorder(V[p].r);
 }
};

Tree T;
int Q;

int main() {
 scanf("%d",&Q);
 rep(i,Q){
  string c;
  { char buf[10]; scanf("%s",buf); c=buf; }
  if(c=="insert"){
   int v; scanf("%u",&v);
   T.insert(v);
  }
  else if(c=="find"){
   int v; scanf("%u",&v);
   if(T.find(v)==-1) printf("no\n"); else printf("yes\n");
  }
  else if(c=="delete"){
   int v; scanf("%u",&v);
   T.erase(T.find(v));
  }
  else if(c=="print"){
   T.printInorder(); printf("\n");
   T.printPreorder(); printf("\n");
  }
 }
}



Measured memory_bytes: 11328
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	int n, m;
	int goals[100000];
	int bet[100000];
	int ans = 0;

	cin >> n >> m;

	rep(i, 0, m) {
		cin >> goals[i];
	}

	sort(goals, goals + m);

	rep(i, 1, m) {
		bet[i - 1] = goals[i] - goals[i - 1];
	}

	sort(bet, bet + m - 1);

	if (m > n) {
		rep(i, 0, m - n) {
			ans += bet[i];
		}
		cout << ans << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define lld long long int 

//-4%3=-1



int main() {
	// your code goes here
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int n,k;
        lld arr[100001],dp[100001];
        cin>>n>>k;
        for(int i=1;i<=n;i++)
        {
            cin>>arr[i];
            dp[i]=INT_MAX;
        }
        dp[1]=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=i+k&&j<=n;j++)
            dp[j]=min(dp[i]+abs(arr[i]-arr[j]),dp[j]);
            //cout<<dp[i]<<" ";
        }
        cout<<dp[n];
    }
}



Measured memory_bytes: 1792
L = []
R = []
N, M = map(int, input().split())
for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

ans = min(R)-max(L)+1
if ans>=1:
    print(ans)
else:
    print(0)

Measured memory_bytes: 55896
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int cnt[220000];

int main() {
	int n, k, a;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a;
		cnt[a - 1]++;
	}
	sort(cnt, cnt + n);
	int ans = 0;
	for (int i = 0; i < n - k; i++)
		ans += cnt[i];
	cout << ans << endl;
}

Measured memory_bytes: 4396
s = str(input())
a_cnt=0
c_cnt=0
l_cnt=0
s_up=s.upper()
if s[0] == 'A':
    a_cnt += 1
for i in range(2,len(s)-1):
    if s[i] == 'C':
        c_cnt += 1

for i in range(len(s)):
    if s_up[i] == s[i]:
        l_cnt += 1

if a_cnt == 1 and c_cnt == 1 and l_cnt == 2:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let c1 = get!(String).chars().collect::<Vec<_>>();
    let c2 = get!(String).chars().rev().collect::<Vec<_>>();
    println!("{}", if c1.into_iter().eq(c2.into_iter()) { "YES" } else { "NO" });
}

Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll 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()
#define SZ(x) ll(x.size())

void yes() {
  cout << "YES" << endl;
  exit(0);
}

void no() {
  cout << "NO" << endl;
  exit(0);
}

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if (v <= w) {
    no();
  }

  ll dv = abs(v - w), dx = abs(a - b);
  if (dx > t * dv) {
    no();
  }

  yes();
}

Measured memory_bytes: 3632
S = list(input())
N = len(S)
sub = 0
(pop) = 0

for i in range(1, N):
    if S[i] == "1":
        if S[i-1] == "0":
            (pop) += 1

        elif S[i-1] == "1":
            S[i] = "0"
            sub += 1

    elif S[i] == "0":
        if S[i-1] == "1":
            (pop) += 1

        elif S[i-1] == "0":
            S[i] = "1"
            sub += 1

print(sub)


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

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  int ans=N;
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<N;i++){
    if(a[i]==-1)continue;
    for(int j=i+1;j<N;j++){
      if(a[i]==a[j]){
        ans--;
        a[j]=-1;
      }
    }
  }
  cout<<ans<<endl;
}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  int t = min(B,D) - max(A,C);
  if(t < 0){
    t = 0;
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,ans,ans1;
    cin>>n>>m;
    if(n==1||m==1)
        {cout<<"1"<<endl;return 0;}
    if(m%2==0)
        {ans=m/2;
        ans1=m/2;}
    else
        {ans=m/2+1; 
        ans1=m/2;}
    if(n%2==0)
        cout<<(ans*(n/2))+(ans1*(n/2))<<endl;
    else
        cout<<(ans*(n/2+1))+(ans1*(n/2))<<endl;
    return 0;
}

Measured memory_bytes: 3648
from collections import deque

h,w = map(int,input().split())
maze = []
ans = 0
dy_dx = [[0,1],[1,0],[0,-1],[-1,0]]
for i in range(h):
    maze.append(input())
flag = True
check = '.'*w
for i in range(h):
    if maze[i] != check:
        flag = False
        break
if flag:
    print(h+w-2)
else:
    for i in range(h):
        for j in range(w):
            if maze[i][j] == '.':
                ne = deque([[i,j]])
                dist = [[0]*w for k in range(h)]
                checked = [[0]*w for k in range(h)]
                while len(ne) != 0:
                    cur = ne.popleft()
                    checked[cur[0]][cur[1]] = 1
                    for l in range(4):
                        t = cur[0]+dy_dx[l][0]
                        u = cur[1]+dy_dx[l][1]
                        if (0 <= t <= h-1) and (0 <= u <= w-1):
                            if checked[t][u] == 0:
                                if maze[t][u] == '.':
                                    dist[t][u] = dist[cur[0]][cur[1]]+1
                                    ne.append([t,u])
                                    ans = max(ans,dist[t][u])
    print(ans)

Measured memory_bytes: 3436
#include<iostream>
using namespace std;
int main(){
    int n=5;
    int arr[n],p;
    for(int i=1;i<=5;i++){
        cin>>arr[i];
        if(arr[i]==0){
        p=i;}
        
    }
    cout<<p<<endl;
    return 0;
    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int head[200010];
int cur[200010];
struct edge {
    int v, c, next;
    edge() {}
    edge(int _v, int _c, int _next) : v(_v), c(_c), next(_next) {}
} e[1500010];
int n, s, t;
int newedge(int v = 0, int c = 0, int next = 0) {
    static int tot = 2;
    return e[tot] = edge(v, c, next), tot++;
}
void addedge(int u, int v, int c) {
    head[u] = newedge(v, c, head[u]);
    head[v] = newedge(u, 0, head[v]);
}
int d[200010];
int bfs() {
    memset(d, -1, sizeof d);
    queue < int > q;
    q.push(0);
    d[s] = 1;
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (int i = head[now]; i; i = e[i].next)
            if (e[i].c > 0 && d[e[i].v] == -1)
                d[e[i].v] = d[now] + 1, q.push(e[i].v);
    }
    memcpy(cur, head, sizeof cur);
    return d[t] > 0;
}
int dfs(int now = 0, int limit = 0x7fffffff) {
    if (now == t)
        return limit;
    int ans = 0;
    for (int &i = cur[now]; i; i = e[i].next) {
        if (d[e[i].v] != d[now] + 1 || e[i].c == 0)
            continue;
        int a = dfs(e[i].v, min(e[i].c, limit));
        limit -= a;
        ans += a;
        e[i].c -= a;
        e[i ^ 1].c += a;
        if (limit == 0)
            break;
    }
    return ans;
}
int tmp[200010], to[200010], fa[200010];
int main() {
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int cnt;
        scanf("%d", &cnt);
        while (cnt--) {
            int x;
            scanf("%d", &x);
            addedge(i, n - 1 + x, 1);
        }
    }
    s = 0, t = n + n;
    memcpy(tmp, head, sizeof tmp);
    for (int i = 1; i < n; i++) addedge(s, i, 1), addedge(i + n - 1, t, 1);
    int ans = 0;
    while (bfs())
        ans += dfs();
    memcpy(head, tmp, sizeof tmp);
    if (ans != n - 1) return puts("-1"), 0;
    for (int i = 1; i < n; i++) {
        for (int j = head[i]; j; j = e[j].next) if (e[j].c == 0) assert(to[i] == 0), to[i] = e[j].v - n + 1;
        assert(to[i] < n);
        assert(to[i]);
    }
    queue < int > q;
    q.push(n);
    int cnt = 0;
    while (!q.empty()) {
        cnt++;
        int now = q.front();
        q.pop();
        for (int i = head[now + n - 1]; i; i = e[i].next) {
            if (!fa[e[i].v]) {
                q.push(to[e[i].v]);
                fa[e[i].v] = now;
            }
        }
    }
    if (cnt != n) return puts("-1"), 0;
    for (int i = 1; i < n; i++) printf("%d %d\n", fa[i], to[i]);
}

Measured memory_bytes: 17020
#include<iostream>
using namespace std;
int main()
{
	long  a,b,n,p;
	while((cin>>a>>b>>n)!=0){
		p=0;
		a=a%b;
		for(int i=0;i<n;i++){
			a=a*10;
			p=p+(a/b)%10;
			a=a%b;			
		}
		cout<<p<<endl;		
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    ll x[n],y[n];
    rep(i,n)cin>>x[i]>>y[i];
    map<pair<int,int>,int> mp;
    rep(i,n)rep(j,n){
        if(i==j)continue;
        mp[{x[i]-x[j],y[i]-y[j]}]++;
    }
    int ans = 0;
    for(auto p : mp){
        ans = max(ans,p.second);
    }
    cout<<n-ans<<endl;
    return 0;
}

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

int main() {
    string s; cin >> s;
    stack<int> st;
    int cnt=0;
    int z = (int)s.at(0) - '0';
    st.push(z);

    for(int i=1; i<s.size(); i++){

        int y = (int)s.at(i) - '0';
        if(st.empty()) {
            st.push(y);
            continue;
        }
        int x = st.top();
        //cout << x << " " << y << endl;
        if(x^y==1){
            st.pop();
            cnt++;
        }
        else st.push(y);
    }

    cout << 2*cnt << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<numeric>
#include<map>
#include<limits>
using namespace std;

#define R(i,s,n) for(int i=s;i<n;i++)
#define D(i,n,s) for(int i=n-1;i>=s;i--)
typedef pair<int,int> P;
typedef unsigned long long ull;
typedef long long ll;

int n,m,t,p;

int main() {
  while(cin >> n >> m >> t >> p && !(!n && !m && !t && !p)){
    //初期化
    int d[t],c[t],x[p],y[p];
    R(i,0,t){
      cin >> d[i] >> c[i];
    }
    R(i,0,p){
      cin >> x[i] >> y[i];
    }
    vector< vector<int> > t1(32,vector<int>(32,0));
    R(i,0,m){
      R(j,0,n){
        t1[i][j] = 1;
      }
    }

    //折る
    //d=1左,d=2上
    R(oru,0,t){
      vector< vector<int> > t2(32,vector<int>(32,0));
      R(i,0,m){
        R(j,0,n){
          if(d[oru] == 1){
            if(c[oru]-j-1 >= 0) t2[i][j] += t1[i][c[oru]-j-1];
          }else{
            if(c[oru]-i-1 >= 0) t2[i][j] += t1[c[oru]-i-1][j];
          }
          if((d[oru]==1?j+c[oru]:i+c[oru]) >= 32)continue;
          t2[i][j] += t1[d[oru]==2?i+c[oru]:i][d[oru]==1?j+c[oru]:j];
        }
      }
      /*
      D(i,d[oru]==1?m:c[oru],0){
        D(j,d[oru]==2?n:c[oru],0){
          t2[d[oru]==1?m-i-1:c[oru]-i-1][d[oru]==2?n-j-1:c[oru]-j-1] += t1[i][j];
        }
      }*/
      t1 = t2;
    }
    /*
    R(i,0,32){
      R(j,0,32){
        cout << t1[i][j] << " ";
      }
      cout << endl;
    }
    */
    //穴
    R(ana,0,p){
      cout << t1[y[ana]][x[ana]] << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
#define bug(a)       cerr << #a << " : " << a << endl;
#define itc(n) char(n+48)
#define cti(ch) (ch-48)

ll n,W,w[1005],p[1005],dp[105][200005];
ll Knapsack(ll pos, ll pw)
{
    if(pos>=n)return 0;
    ll p1 , p2;
    if(dp[pos][pw] !=  -1)return dp[pos][pw];
    if(pw + w[pos] <= W) p2 = Knapsack(pos + 1 , pw + w[pos]) + p[pos];
    else p2 = 0;
    p1 = Knapsack(pos + 1 , pw);
    dp[pos][pw] = max(p1 , p2);
    return dp[pos][pw];
}


int main()
{
    faster_io;

    cin>>n>>W;
    memset(dp,-1,sizeof dp);

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

    cout<<Knapsack(0,0)<<endl;

    return 0;
}


Measured memory_bytes: 164352
#include<bits/stdc++.h>
using namespace std;
int problem[107];
int main(){
    int n;
    scanf("%d",&n);
    int a,b;
    scanf("%d%d",&a,&b);
    int num_a=0,num_b=0,num_c=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&problem[i]);
        if(problem[i]<=a)
            num_a++;
        else if(problem[i]>a&&problem[i]<=b)
            num_b++;
        else if(problem[i]>b)
            num_c++;
    }
    int ans=min(num_a,num_b);
    ans=min(ans,num_c);
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1166&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

#define INF 1000

int W,H;
int vertical[30][30];
int horizontal[30][30];
int maze[30][30];

void init()
{
	fill_n((int *)vertical, sizeof(vertical) / sizeof(int), 0);
	fill_n((int *)horizontal, sizeof(horizontal) / sizeof(int), 0);
	fill_n((int *)maze, sizeof(maze) / sizeof(int), INF);
}

void dfs(int x, int y, int deep)
{

	if(x < 0 || x > W || y < 0 || y > H){ return; }

	if(maze[y][x] <= deep){ return; }

	maze[y][x] = deep;

	if(x < W-1 && !vertical[y][x]){ dfs(x+1, y, deep+1); } //右
	if(x > 0 && !vertical[y][x-1]){ dfs(x-1, y, deep+1); } //左
	if(y > 0 && !horizontal[y-1][x]){ dfs(x, y-1, deep+1); } //上
	if(y < H-1 && !horizontal[y][x]){ dfs(x, y+1, deep+1);} //下
	return;
}

int main()
{
	while(cin >> W >> H && H)
	{
		init();
		rep(h,H-1)
		{
			rep(w,W-1){
				cin >> vertical[h][w];
			}
			rep(w,W){
				cin >> horizontal[h][w];
			}
		}

		rep(w,W-1){
			cin >> vertical[H-1][w];
		}

		dfs(0,0,1);

		cout << ( maze[H-1][W-1] != INF ? maze[H-1][W-1] : 0 ) << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  int n,i,j;
  scanf("%d ",&n);
  double a[n];
  vector<vector<double>>dp(n,vector<double>(n+1,0.0));
  for(i=0;i<n;i++){
    scanf("%lf",&a[i]);
  }
  dp[0][0] = (1.0-a[0]);
  dp[0][1] = a[0];
  double prod = 1-a[0];
  for(i=1;i<n;i++){
    prod *= (1-a[i]);
    dp[i][0] = prod;
    for(j=1;j<=i+1;j++){
      dp[i][j] = dp[i-1][j-1]*a[i] + dp[i-1][j]*(1-a[i]);
    }
  }
  double sum = 0;
  for(i=n/2+1;i<=n;i++){
    sum+=dp[n-1][i];
    //cout<<dp[n-1][i]<<"\n";
  }
  printf("%0.10lf",sum);
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define INF 1e+9
#define MAX_V 100300
using P = pair<int,int>;
struct edge{
    int to;
    int cost;
};
vector <edge> G[MAX_V]; //グラフ
vector <int> d1(MAX_V, INF);// 距離
vector <int> d2(MAX_V, INF);
void dijkstra(int s, vector <int> &d){
    priority_queue<P, vector<P>, greater<P> > que;
    d[s] = 0;
    que.push(P(0,s)); // 今までのコストと現在地
    
    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v]< p.first) continue;
        
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
int main(void){
    int n; cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b; cin>>a>>b; a--; b--;
        G[a].push_back({b,1});
        G[b].push_back({a,1});
    }
    dijkstra(0, d1);
    dijkstra(n-1, d2);
    int feneko=0, snuke=0;
    for(int i=0;i<n;i++){
            if(d1[i]>d2[i]) snuke++;
            else feneko++;
    }
    if(feneko>snuke) cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}


Measured memory_bytes: 7536
using System;
using System.Collections.Generic;

namespace Contest
{

    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private void Scan()
        {
            Scanner sc = new Scanner();
            N = sc.NextInt();
        }

        public void Solve()
        {
            Scan();
            for (int i = 0; i < 25; i++)
            {
                for (int j = 0; j < 15; j++)
                {
                    if (4 * i + 7 * j == N)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");
        }

        static void Main() => new Program().Solve();
    }
}

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

vector<int> xa,ya;
string str;
int x,y,dpx[4000][16010],dpy[4000][16010];

int solvex(int pos,int amo)
{
    if(pos>=xa.size())
    {
        if(amo==x+8000) return dpx[pos][amo]=1;
        else return dpx[pos][amo]=0;
    }
    if(dpx[pos][amo]!=-1) return dpx[pos][amo];

    int ret=solvex(pos+1,amo+xa[pos]) || solvex(pos+1,amo-xa[pos]);

    return dpx[pos][amo]=ret;

}

int solvey(int pos,int amo)
{
    if(dpy[pos][amo]!=-1) return dpy[pos][amo];
    if(pos==ya.size())
    {
        if(amo==y+8000) return dpy[pos][amo]=1;
        else return dpy[pos][amo]=0;
    }

    int ret=solvey(pos+1,amo+ya[pos]) || solvey(pos+1,amo-ya[pos]);

    return dpy[pos][amo]=ret;

}

int main()
{
    cin>>str;
    cin>>x>>y;
    int u=0,v=0;
    for(int i=0; i<str.size(); i++)
    {
        u=0;
        while(str[i]=='F' && i<str.size()) u++,i++;


        if(v==0) xa.push_back(u);
        else ya.push_back(u);

        v=(v+1)%2;
        //i--;
        //printf("%d\n",u);
    }
    /*for(int i=0;i<xa.size();i++) printf("%d ",xa[i]);
    printf("\n");
    for(int i=0;i<ya.size();i++) printf("%d ",ya[i]);
    printf("\n");*/
    memset(dpx,-1,sizeof(dpx));
    memset(dpy,-1,sizeof(dpy));
    int rx=0,ry=0;
    if(xa.size()>0) rx=solvex(1,xa[0]+8000);
    ry=solvey(0,8000);

    if(rx>0 && ry>0) printf("Yes\n");
    else printf("No\n");
}


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    //my-code
    int s,w; cin >> s >> w;
    if (w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
        int n;
        while((cin >> n)){
                int x = 0;
                for(int i = 0 ; i < 10 ; i++){
                        for(int j = 0 ; j < 10 ; j++){
                                for(int k = 0 ; k < 10 ; k++){
                                        for(int l = 0 ; l < 10 ; l++){
                                                if(i+j+k+l == n)
                                                        x++;
                                        }   
                                }   
                        }   
                }   
                cout << x << endl;
        }   
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
ll n;
ll tree[4*MAXN];
vector<ii> v;
ll a[MAXN];

void build(ll node, ll l, ll r){
    if(l>r){
        return;
    }
    if(l==r){
        tree[node]=a[l];
        return;
    }
    ll mid = (l+r)/2;
    build(2*node+1, l, mid);
    build(2*node+2, mid+1, r);
    tree[node] = max(tree[2*node+1], tree[2*node+2]);
}

void update(ll node, ll l, ll r, ll pos, ll val){
    if((l>r) || (l>pos) || (r<pos)){
        return;
    }
    if((l==r) && (l==pos)){
        tree[node]=val;
        a[l]=val;
        return;
    }
    ll mid = (l+r)/2;
    update(2*node+1, l, mid, pos, val);
    update(2*node+2, mid+1, r, pos, val);
    tree[node] = max(tree[2*node+1], tree[2*node+2]);
}

ll query(ll node, ll l, ll r, ll start, ll end){
    if((l>r) || (l>end) || (r<start)){
        return 0;
    }
    if((l>=start) && (r<=end)){
        return tree[node];
    }
    ll mid = (l+r)/2;
    ll z1 = query(2*node+1, l, mid, start, end);
    ll z2 = query(2*node+2, mid+1, r, start, end);
    return max(z1, z2);
}

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
        ll h;
        cin>>h;
        v.push_back({h, i});
    }
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    sort(v.begin(), v.end());

    for (int i = 0; i < v.size(); ++i)
    {
        ll ind = v[i].S;
        ll max1=0;
        if(ind==0){
            max1=a[0];
            update(0, 0, n-1, 0, a[i]);
        }
        else{
            max1=query(0, 0, n-1, 0, ind-1)+a[ind];
        }
        update(0, 0, n-1, ind, max1);
    }

    cout<<query(0, 0, n-1, 0, n-1);

    return 0;
}


Measured memory_bytes: 12156
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    // ll [n];
    // ld x=2*sqrt(a)*sqrt(b);
    // if(c-a-b-x>0){
    //     printf("Yes\n");
    // }else{
    //     ld ra=sqrt(a),rb=sqrt(b),rc=sqrt(c);
    //     if(c-a-b-x==0){
    //         if()
    //     }
    //     printf("No\n");
    // }
    if( 4*a*b< (c-a-b)*(c-a-b) && c-a-b>0 ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    for (int i = 3; i <= n; i++) {
        if (i%3==0) cout << ' ' << i;
        else
        {
            int x = i;
            while (x) {
                if (x%10 == 3) {
                    cout << ' ' << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3116
#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
// https://atcoder.jp/contests/abc169/tasks/abc169_e
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll ans = 0;
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i = 0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    if(n%2 == 0){
        ll ax = b[n/2] + b[(n/2)-1];
        ll in = a[n/2] + a[(n/2)-1];
        ans = ax - in + 1;
    }
    else{
        ll ax = b[n/2];
        ll in = a[n/2];
        ans = ax - in + 1;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 6324
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll H, N;
  cin >> H >> N;
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  vector<vector<ll>> table(N, vector<ll>(H+1));
  for (ll i = 0; i <= H; i++) {
    ll num = i;
    while(num > 0) {
      table[0][i] += B[0];
      num -= A[0];
    }
  }
  for (ll i = 1; i < N; i++) {
    for (ll j = 1; j <= H; j++) {
      ll old = table[i-1][j];
      ll cand_j = max(0LL, j - A[i]);
      ll cand = table[i][cand_j] + B[i];
      table[i][j] = min(old, cand);
    }
  }

  cout << table[N-1][H] << endl;
  return 0;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

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

  cout << (a-b+1)*(a-c+1) <<endl;
  
}


Measured memory_bytes: 256
import sys
count={chr(97+i):0 for i in range(26)}
line=sys.stdin.read()
line=line.lower()

for i in range(len(line)):
    if line[i] in count:
        count[line[i]]+=1

for i in range(97,97+26):
    print(chr(i)+' : '+str(count[chr(i)]))


Measured memory_bytes: 5572
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    s = [0] * N
    for i in range(N):
        s[i] = int(input())

    s.sort()
    ans = sum(s)
    if ans % 10 == 0:
        for i in range(N):
            if s[i] % 10 != 0:
                ans -= s[i]
                break
        if i == N - 1:
            ans = 0
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060