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

void leap(int a, int b);
bool check(int a);

int main(void){
  int a,b;
  bool begin=true;
  while(1){
    cin>>a>>b;
    if(a==0 && b==0)break;
    if(begin==false)cout<<endl;
    leap(a,b);
    begin=false;
  }
}

void leap(int a, int b){
  vector<int> year;
  for(int i=a;i<=b;i++){
    if(check(i)){
      year.push_back(i);
    }
  }
  if(year.size()==0){
    cout<<"NA"<<endl;
  }
  else{
    for(int i=0;i<year.size();i++){
      cout<<year[i]<<endl;
    }
  }
}

bool check(int a){
  if(a%400==0){return true;}
  else if(a%100==0){return false;}
  else if(a%4==0){return true;}
  else{return false;}
}



Measured memory_bytes: 3148
def main():
 n,y = map(int,input().split())
 flag = 0
 for i in range(n + 1):
     for j in range(n - i + 1):
         if flag == 0 and  i * 10000 + j * 5000 + 1000 * (n - i - j) == y:
             flag = 1
             print(i,j,n - i - j)
 if flag == 0:
     print('-1 -1 -1')
main()

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

using namespace std;

using ull = uint64_t;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N;
   cin >> N;
   vector<vector<int>> adj(N);
   for (int i = 0; i < N - 1; ++i) {
      int v, u;
      cin >> v >> u;
      adj[--v].emplace_back(--u);
      adj[u].emplace_back(v);
   }
   int dep;
   ull ans = numeric_limits<ull>::max();
   vector<int> diam;
   {
      vector<int> par(N);
      int start = 0;
      for (int z = 0; z < 2; ++z) {
         fill(par.begin(), par.end(), -1);
         vector<int> bfs;
         bfs.emplace_back(start);
         for (int i = 0; i < N; ++i) {
            int v = bfs[i];
            for (int u : adj[v]) if (u != par[v]) {
               par[u] = v;
               bfs.emplace_back(u);
            }
         }
         start = bfs.back();
      }
      while (~start) {
         diam.emplace_back(start);
         start = par[start];
      }
   }
   vector<int> deg(N);
   function<void(int, int, int d)> dfs = [&](int v, int p, int d) {
      deg[d] = max(deg[d], int(adj[v].size()) - (p != -1));
      for (int u : adj[v]) if (u != p) {
         dfs(u, v, d + 1);
      }
   };
   if (diam.size() % 2 == 0) {
      dep = diam.size() / 2;
      int v0 = diam[(diam.size() / 2) - 1];
      int v1 = diam[(diam.size()) / 2];
      fill(deg.begin(), deg.end(), 0);
      dfs(v0, v1, 0);
      dfs(v1, v0, 0);
      ull cur = 2;
      for (int i = 0; i < dep - 1; ++i) cur *= deg[i];
      ans = cur;
   } else {
      int v = diam[diam.size() / 2];
      dep = (diam.size() + 1) / 2;
      fill(deg.begin(), deg.end(), 0);
      dfs(v, -1, 0);
      ull cur = 1;
      for (int i = 0; i < dep - 1; ++i) cur *= deg[i];
      ans = min(ans, cur);
      for (int u : adj[v]) {
         fill(deg.begin(), deg.end(), 0);
         dfs(v, u, 0);
         dfs(u, v, 0);
         ull cur = 2;
         for (int i = 0; i < dep - 1; ++i) cur *= deg[i];
         ans = min(ans, cur);
      }
   }
   cout << dep << " " << ans << "\n";
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    long long K;
    cin>>S>>K;
    int SIZE=S.size();
    for(int i=0;i<K;i++){
        if(S[i]!='1'){cout<<S[i]<<endl;exit(0);}
    }
    cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll fact[200003];
ll ifact[200003];
ll Combination(ll a,ll b) {
  ll s = (fact[a] * ifact[b]) % Mod;
  return (s * ifact[a-b]) % Mod;
}
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
int main() {
  fact[0] = 1;
  ifact[0] = 1;
  for (int i = 1; i <= 200003; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= Mod;
    ifact[i] = modinv(fact[i],Mod);
  }
  int N;
  cin >> N;
  ll M;
  cin >> M;
  vector<pair<ll,ll>> Pri = prime_factorize(M);
  ll ans = 1;
  for (int i = 0; i < Pri.size(); i++) {
    ans *= Combination(N+Pri[i].second-1,Pri[i].second);
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long long mod =1e9+7;


int main(){
  int R,G,P;
  cin >> R >> G;

  P = 2*G-R;
  cout << P << endl;

    return 0;
}
 

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
    if(u==NIL) return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}
void inParse(int u){
    if(u==NIL) return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}
void postParse(int u){
    if(u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}

int main(){
    int i,v,l,r,root;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        T[i].p=NIL;
    }
    for(i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL) T[l].p=v;
        if(r!=NIL) T[r].p=v;
    }
    
    for(i=0;i<n;i++) if(T[i].p==NIL) root=i;
    
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 2700
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    a: usize,
    b: usize,
    k: usize
    }
    let mut l = vec![];
    for i in 1..=a {
        if a % i == 0 && b % i == 0 {l.push(i)}
    }
    println!("{}", l[l.len() - k])

}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define LOWB(x) (x & (-x))
#define UNIQUE(a) sort(ALL(a)), (a).erase(unique(ALL(a)), (a).end())
#define INF 1e9
#define INF_LL 4e18
#define rep(i,a,b) for(__typeof(b) i=a; i<(b); ++i)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
/*-----------------------------------*/
int n;
vi a, pre, nxt;

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main() {
  cin >> n;
  a.resize(n);
  pre.resize(n);
  nxt.resize(n);
  for (int i=0; i<n; i++) cin >> a[i];
  
  pre[1] = a[0];
  for (int i=2; i<n; i++) pre[i] = gcd(a[i-1], pre[i-1]);
  nxt[n-2] = a[n-1];
  for (int i=n-3; i>=0; i--) nxt[i] = gcd(a[i+1], nxt[i+1]);

  int best = 0;
  best = max(best, nxt[0]);
  best = max(best, pre[n-1]);

  for (int i=1; i<n-1; i++) best = max(best, gcd(pre[i], nxt[i]));
  cout << best << endl;
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
string S;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>S;
	S[K-1]+='a'-'A';
	cout<<S<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  //direction arrays
  int dx[8]={0,0,-1,+1,+1,-1,+1,-1};
  int dy[8]={+1,-1,0,0,+1,-1,-1,+1};
  
  int32_t main()
  { 
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
    
    IOS
    int n,m,u,v;
    cin>>n>>m;
    int good=0;
    vector<int> h(n+1,0);
    for(int i=1;i<=n;i++)
    {
      cin>>h[i];
    }
    vector<vector<int>> g(n+1);
    for(int i=0;i<m;i++)
    {
      cin>>u>>v;
      g[u].push_back(v);
      g[v].push_back(u);

    }
    for(int i=1;i<=n;i++)
    {
      if(g[i].size()==0)
      {
        good++;
        continue;
      }
      bool flag=true;
      for(auto j:g[i])
      {
           if(h[i]>h[j])
            continue;
           else
           {
            flag=false;
            break;
           }
      }
      if(flag) good++;
    }
    cout<<good;
    
    return 0;
  }
    

Measured memory_bytes: 9748
n=int(input())
s=[input() for i in range(n)]
ac=s.count("AC")
wa=s.count("WA")
tle=s.count("TLE")
re=s.count("RE")

print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

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

int main() {
  int w,h,x,y;
  cin >> w >> h >> x >> y;
  double ans = (double)w*h/2;
  int num = (w==x*2 && h==y*2) ? 1 : 0;
  printf("%.10f %d\n", ans, num);
  return 0;
  
}


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

int main()
{
    int n;
    cin >> n;
    int v[n];
    ll dp[n][n];
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (int l = n - 1; l >= 0; l--)
    {
        for (int r = l; r < n; r++)
        {
            if (l == r)
            {
                dp[l][r] = v[l];
            }
            else
            {
                dp[l][r] = max(v[l] - dp[l + 1][r], v[r] - dp[l][r - 1]);
            }
        }
    }
    /*for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cout << dp[i][j] << " ";
		}
		cout << "\n";
	}*/
    cout << dp[0][n - 1] << "\n";
    return 0;
}

Measured memory_bytes: 70144
#include<bits/stdc++.h>
#define rgt register
#define rint rgt int
#define LL long long
#define rll rgt LL
#define inf 0x7f7f7f7f
#define N 100007
using namespace std;
template<class K>inline bool cmax(K&a,const K&b){return(a<b)?a=b,1:0;}
template<class K>inline bool cmin(K&a,const K&b){return(a>b)?a=b,1:0;}
inline int read() {
	rgt int s=0;
	rgt char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return s;
}
struct node{
	int x,i;LL sum;
}b[N];
int n,t;
LL Ans[N],sum;
inline bool cmp(rgt node a,rgt node b) {
	return (a.x!=b.x)?a.x>b.x:a.i<b.i;
}
int main() {
	rint i,c=inf;n=read();
	for(i=1;i<=n;i++) b[i].x=read(),b[i].i=i;
	sort(b+1,b+n+1,cmp);
	for(i=1;i<=n;i++) {
		if(b[i].x!=b[i-1].x) b[++t]=b[i],b[t].sum=1;
		else ++b[t].sum;
	}
	b[t+1].x=0;
	for(i=1;i<=t;i++) {
		cmin(c,b[i].i),sum+=b[i].sum;
		Ans[c]+=sum*(b[i].x-b[i+1].x);
	}
	for(i=1;i<=n;i++) printf("%lld\n",Ans[i]);
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    ll c[10][10]={};
    REP(i,N){
        string s=to_string(i+1);
        c[s[0]-'0'][s.back()-'0']++;
    }
    ll ans=0;
    REP(i,10) REP(j,10){
        ans+=c[i][j]*c[j][i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll N;
vl a;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    a = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> a[i];
    }
    solve();
}

// 与えられる入力は全て整数
// 1 <= N, a_i <= 100

// ll N, vl a
// 問題文中の 2 つの条件の両方を満たすマスの個数を出力せよ。
void solve(){
    ll ans=0;
    rep(i,N){
        if(i%2==0&&a[i]%2==1)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){

int x,y,b,p;

int n;

cin>>n;
for(int i=0;i<n;i++)
{
cin>>x>>y>>b>>p;
int s1=0,s2=0,s3=0,s4=0;
int nb=0,np=0;
nb=b/5;
np=p/2;
int sb=0,sp=0;
if(nb==0)s4+=5*x*8/10;
else{s4+=b*x*8/10;}

if(np==0)s4+=2*y*8/10;
else{s4+=p*y*8/10;}

if(np==0)np=1;
if(nb==0)nb=1;
s1=(nb*x*5+np*y*2)*8/10;
s1+=(b%5)*x+(p%2)*y;

s2=((nb+1)*5*x+(np+1)*2*y);

s3=(b)*x+(p)*y;

int S=s1;
if(S>s2){S=s2;}
if(S>s3){S=s3;}
if(S>s4){S=s4;}
//if(S==s1)cout<<"s1*";

cout<<S<<endl;
}
return 0;
} 

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll a,b;
  cin >> a >> b;
  ll ans=0;
  ans+=a-1;
  if(a<=b) ans++;
  pr(ans);
}

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


Measured memory_bytes: 256
/*input
6
010110
101001
010100
101000
100000
010000
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
vector<int> v[maxn];
bool vis[maxn];
int depth[maxn];
bool cyc=false;
void iscyc(int u,int par,int d){
    vis[u]=1;
    depth[u]=d;
    for(auto x:v[u]){

        if(!vis[x]){
            iscyc(x,u,d+1);
        }
        else if(x!=par and depth[x]!=depth[u]-1) cyc=true;
    }
    
}

int main(){
    int n;
    cin>>n;
    vector<pii> ed;
    REP(i,n){
        REP(j,n){
            char x;
            cin>>x;
            if(x=='1'){
                v[i].pb(j);
                ed.pb({i,j});
            }
        }
    }   
    FILL(vis,false);
    int mx=-1;
    REP(st,n){
        queue<int> q;
        q.push(st);
        FILL(depth,0);
        depth[st]=1;
        bool wk=true;
        while(!q.empty()){
            int x=q.front();
            q.pop();

            for(auto z:v[x]){
                if(depth[z]==0){
                    depth[z]=depth[x]+1;
                    q.push(z);
                }
                else if(abs(depth[z]-depth[x])!=1){
                    wk=false;
                }
            }
        }
        for(auto x:ed){
            if(abs(depth[x.f]-depth[x.s])!=1){
                wk=false;
            }
        }
        if(wk){
            REP(i,n){
                mx=max(mx,depth[i]);
            }

        }
    }
    cout<<mx;
}

Measured memory_bytes: 1528
s=list(input())
k=int(input())

from collections import Counter
l=Counter(s)
if len(l)==1:
    print(len(s)*k//2)
    exit()

f=1
ans=0
for i in range(len(s)-1):
    if f and s[i]==s[i+1]:
        ans+=1
        f=0
    else:
        f=1

if s[0]!=s[-1]:
    print(ans*k)
else:
    ans2=0
    ss=s+s
    f=1
    for i in range(2*len(s)-1):
        if f and ss[i]==ss[i+1]:
            ans2+=1
            f=0
        else:
            f=1
    print(ans+(ans2-ans)*(k-1))


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


int A, B, C;


void input() {
    cin >> A >> B >> C;
}


int main() {
    input();
    set<int> s;
    s.insert(A);
    s.insert(B);
    s.insert(C);
    if (s.size() == 2) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
N,M,D = map(int, input().split())
field = [list(input()) for _ in range(N)]
sum = 0

for y in range(N):
	count = 0
	for x in range(M):
		if field[y][x] == '.':
			count += 1
			continue
		elif count == 0:
			continue
		elif count >= D:
			sum += count-D+1
			count = 0
			continue
		count = 0
	else:
		if count >= D:
			sum += count-D+1
			count = 0

field = list(zip(*field[::-1]))

for y in range(M):
	count = 0
	for x in range(N):
		if field[y][x] == '.':
			count += 1
			continue
		elif count == 0:
			continue
		elif count >= D:
			sum += count-D+1
			count = 0
			continue
		count = 0
	else:
		if count >= D:
			sum += count-D+1
			count = 0

print(sum)


Measured memory_bytes: 5756
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vp(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    vp.at(i) = {a, b};
  }
  sort(vp.begin(), vp.end());
  ll ans = 0;
  rep(i, n){
    auto now = vp.at(i);
    if(m - now.second > 0){
      ans += (ll)now.first * now.second;
      m -= now.second;
    }else{
      ans += (ll)now.first * m;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){

	int n;
	vector<ll> arr;
	cin>>n;

	arr.resize(n);
	REP(i,n)cin>>arr[i];

	ll max_a = 0;
	ll max_i = -1;
	REP(i,n){
		if(arr[i] > max_a ){
			max_a = arr[i];
			max_i = i;
		}
	}


	ll poll  = max_a / 2;
	ll poll2  = max_a / 2 + 1;

	ll diff_min = INT_MAX;
	ll diff_min_i = -1; 

	if(max_a % 2 == 0){
		REP(i,n){
			
			if(i == max_i)continue;

			if(arr[i] == poll ){
				diff_min_i = i;
				break;
			}

			ll diff = abs(arr[i] - poll);

			if(diff < diff_min ){
				diff_min = diff;
				diff_min_i = i;
			}
		}
	}
	else{
		REP(i,n){
			if(i == max_i)continue;
			
			if(arr[i] == poll || arr[i] == poll2){
				diff_min_i = i;
				break;
			}
			ll diff = abs(arr[i] - poll);

			if(diff < diff_min ){
				diff_min = diff;
				diff_min_i = i;
			}
		}
	}
	
	cout<<max_a<<" "<<arr[diff_min_i]<<endl;
	return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif (N == 1 and M >= 2) or (M == 1 and N > -2):
    print(max(N, M) - 2)
else:
    print((N - 2) * (M - 2))

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
int main(void)
{
	int a,b,c,d,i;
	
	scanf("%d %d",&a,&b);
	c=b-a;
	d=0;
	for(i=1;i<=c;i++)
	{
		d=d+i;
	}
	printf("%d\n",d-b);
	return 0;
}

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

int main() {
    string s, t;
    int ans = 0;
    cin >> s >> t;
    for (int i = 0; i < s.size(); ++i) {
        ans += s[i] != t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3848
#include<iostream>
#include<cstring>
using namespace std;
void ash()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("/home/ashish/Desktop/C++/in.txt", "r", stdin);
    freopen("/home/ashish/Desktop/C++/out.txt", "w", stdout);
#endif
}
int main()
{
    ash();
char str;
  cin>>str;
  if(isupper(str))
  {
cout<<"A";
  }
else{
cout<<"a";

}
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#include<complex>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef complex<double> P;
typedef vector<P> G;
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
P pin(){
	double x,y;
	cin>>x>>y;
	P p(x,y);
	return p;
}
void PIN(P* a,int n){
	rep(i,n)a[i]=pin();
}
double dot(P a,P b){
	return real(conj(a)*b);
}
double cross(P a,P b){
	return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
P projection(L a,P p){
	double t=dot(p-a[0],a[0]-a[1])/norm(a[0]-a[1]);
	return a[0]+t*(a[0]-a[1]);
}
P reflection(L a,P p){
	return p+2.0*(projection(a,p)-p);
}
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P intersect_ls(L a,L b){
	double t1=abs(cross(a[1]-a[0],b[0]-a[0]));
	double t2=abs(cross(a[1]-a[0],b[1]-a[0]));
	return b[0]+(b[1]-b[0])*t1/(t1+t2);
}
double distanceLP(const L &l, const P &p) {
  return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
  return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
  if (intersectLS(l, s)) return 0;
  return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
double area(const G &g){
    double S =0;
    for(int i =0;i <g.size();i++){
        S +=(cross(g[i],g[(i+1)%g.size()]));
    }
    return abs(S/2.0);
}
bool inconvex(const G &g){
	int n=g.size();
	rep(i,n)if(ccw(g[(i+n-1)%n],g[i%n],g[(i+1)%n])==-1)return false;
	return true;
}
int main(){
	int n;
	cin>>n;
	G g(n);
	PIN(&g[0],n);
	cout<<inconvex(g)<<endl;
}

Measured memory_bytes: 1256
n=int(input())
shop=[]
profit=[]
for i in range(n):
  k=list(map(int,input().split()))
  shop.append(k)
for i in range(n):
  k=list(map(int,input().split()))
  profit.append(k)
def dfs(i,flag):
  if i!=10:
    return max(dfs(i+1,flag),dfs(i+1,flag|2**i))
  if flag==0:
    return -10**18
  prof=0
  store=[0]*n
  for j in range(10):
    if (flag)&(2**j)>0:
      for k in range(n):
        store[k]+=shop[k][j]
  for k in range(n):
    prof+=profit[k][store[k]]
  return prof
print(dfs(0,0))

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


int main() {
	int i,n;
	long long a[100000];
	cin >> n;
	long long proud = 1;
	bool flag = false;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0)
		{
			flag = true;
		}
	}

	if (flag) {
		cout << 0 << endl;
	}
	else {
		for (int i = 0; i < n; i++) {
			if (a[i] > 1000000000000000000 / proud) {
				cout << -1 << endl;
				flag = true;
				break;
			}
			proud *= a[i];
		}
		
	}
	if (!flag) cout << proud << endl;
	return 0;
}

Measured memory_bytes: 4412
#include<iostream>

int main(){
    int n, count = 0;
    bool isprime [1000000];
    for(int i = 0; i < 1000000; i++)
        isprime[i] = true;
    isprime[0] = isprime[1] = false;
    for(int i = 2; i <= 1000; i++){
        if(isprime[i]){
            for(int j = i * 2; j < 1000000; j += i){
                isprime[j] = false;
            }
        }
    }
    while(std::cin >> n){
        count = 0;
        for(int i = 2; i <= n; i++){
            if(isprime[i])
                count++;
        }
        std::cout << count << std::endl;
    }
}

Measured memory_bytes: 2136
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N, K;
	//long int h[1000000];
	cin >> N >> K;
	int ans = 1000000000;
	int a;
	vector<long int >h;
	for (int i=0; i < N; i++) {
		int x;
		cin >> x;
		h.push_back(x);
	}
	sort(h.begin(), h.end());
	for (int j = 0; j < N - K + 1; j++) {
		a = h[j + K - 1] - h[j];
		if (a < ans) {
			ans = a;
		}
	}
	cout << ans << endl;
}

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

void dfs(int pos){
}

int main(){

    int N;
    cin >> N;
    vector<vector<int>> F(N, vector<int>(10));
    for(int i = 0; i < N; i++) for(int j = 0; j < 10; j++) cin >> F[i][j];
    vector<vector<int>> P(N, vector<int>(11));
    for(int i = 0; i < N; i++) for(int j = 0; j <= 10; j++) cin >> P[i][j];

    int ans = -(1 << 30);
    for(int bit = 1; bit < (1 << 10); bit++){
        int sum = 0;
        for(int i = 0; i < N; i++){
            int count = 0;
            for(int j = 0; j < 10; j++) if((bit >> j & 1) && F[i][j]) count++;
            sum += P[i][count]; 
        }
        ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  for (int i=a; i<=b; ++i){
    if (i%k==0){
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
  return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.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

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
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);}
/*GCD*/
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*LCM*/
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(void){
    ll a,b,c,d,ans=0;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    ans=b-a+1- (b/c-(a-1)/c) - (b/d-(a-1)/d) + (b/lcm(c,d)-(a-1)/lcm(c,d));
    printf("%lld\n",ans);
    return 0;
}


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


int main() {
	int N;
	char s[100];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> s[i];
	int sum = 0;
	int M = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'I') sum++;
		else if (s[i] == 'D') sum--;

		if (M < sum) M = sum;
	}
	cout << M << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

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

   vector<int> ab(n);
   vector<int> ba(n);
   vector<int> a(n);
   vector<int> b(n);

   for(int i=0;i<n;i++){
      if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A')ba[i]++;
      else if(s[i][0] == 'B')b[i]++;
      else if(s[i][s[i].size()-1] == 'A')a[i]++;

      for(int j=0;j<s[i].size()-1;j++){
         if(s[i][j] == 'A' && s[i][j+1] == 'B')ab[i]++;
      }
   }
   int sumAB,sumBA,sumA,sumB;
   sumAB = accumulate(ALL(ab),0);
   sumBA = accumulate(ALL(ba),0);
   sumA = accumulate(ALL(a),0);
   sumB = accumulate(ALL(b),0);

   if(sumA+sumB > 0){
      cout << sumAB + sumBA + min(sumA,sumB) << endl;
   }else if(sumBA -1 >=0){
      cout << sumAB + sumBA - 1 << endl;
   }else{
      cout << sumAB << endl;
   }
   return 0;
}


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

int main(){
	int n;
	long long a=0, c=0, h=0, m=0, r=0, ans=0;
	cin >> n;
	string s;
	for(int i=0; i<n; i++){
		cin >> s;
		if(s[0]=='A') a++;
		else if(s[0]=='C') c++;
		else if(s[0]=='H') h++;
		else if(s[0]=='M') m++;
		else if(s[0]=='R') r++;
	}
	ans += a*(c*h+c*m+c*r+h*m+h*r+m*r) + c*(h*m+h*r+m*r) + h*m*r;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int A[110];
bool F[100100];
int main()
{
  int N,K;
  cin>>N>>K;
  for(int i=0;i<N;i++)
    cin>>A[i];
  for(int i=1;i<=K;i++)
    for(int j=0;j<N;j++)
      if(i>=A[j])
        F[i]|=(1-F[i-A[j]]);
  if(F[K])
    puts("First");
  else	puts("Second");
  return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 100;
ii e[N];
int f[N];

int find(int x) {
  if (f[x] != f[f[x]]) f[x] = find(f[x]);
  return f[x];
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &e[i].first, &e[i].second);
    --e[i].first; --e[i].second;
  }
  int ret = 0;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) f[j] = j;
    int cnt = 0;
    for (int j = 0; j < m; ++j) {
      if (j == i) continue;
      int x = e[j].first, y = e[j].second;
      int rx = find(x), ry = find(y);
      if (rx != ry) {
        f[ry] = rx;
        ++cnt;
      }
    }
    if (cnt < n - 1) ++ret;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        
        if (X<A) {
            System.out.println("0");
        }else {
            System.out.println("10");
        }
    }
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






long long int gcd(long long int a,long long int b)
{
 
  long long int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,m;
  cin>>n>>m;
  if(n==1 && m==1){
    cout<<1<<endl;
  }else if(n==1){
    cout<<m-2<<endl;
  }else if(m==1){
    cout<<n-2<<endl;
  }else{
    cout<<(m-2)*(n-2)<<endl;
  }
}
///////////////////////////



Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
static Scanner scan = new Scanner(System.in);
    public static void main(String[] args) {
        int num = scan.nextInt();
        int sum=0;
        int numCopy = num;

        while(num>0)
        {
            int n = num % 10;
            sum += n;
            num /= 10;
        }

        if(numCopy % sum == 0)
        {
            System.out.println("Yes");
        }else{
            
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
import numpy as np

N = 5
ARR1 = [3, 2, 2, 4, 1]
ARR2 = [1, 2, 2, 2, 1]

N = 4
ARR1 = [1, 1, 1, 1]
ARR2 = [1, 1, 1, 1]

N = 7
ARR1 = [3, 3, 4, 5, 4, 5, 3]
ARR2 = [5, 3, 4, 4, 2, 3, 2]

N = int(input())
ARR1 = [int(s) for s in input().split(" ")]
ARR2 = [int(s) for s in input().split(" ")]


def calculate(n, arr1, arr2):
    arr1 = np.array(arr1)
    arr2 = np.array(arr2)

    k = 0

    res = [np.sum(arr1) + arr2[n-1]]

    for i in range(n+1):
        s1 = np.sum(arr1[:i+1])
        s2 = np.sum(arr2[i:])
        res.append(s1 + s2)

    print(max(res))

calculate(N, ARR1, ARR2)

Measured memory_bytes: 12504
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

#####################################


#2:26
n,a,b = list(map(int, input().split()))
ans=[]
if(n<a+b-1 or n>a*b):
    print(-1)
else:
    if(b>=2):
        x = (n-a)//(b-1)
        y = (n-a)%(b-1)
    else:
        x=1
        y=1
    times=[0 for i in range(b-1)]
    for i in range(a):
        ans.append(n-a+i+1)
    for i in range(b-1):
        if(i<y):
            times[i]=x+1
        else:
            times[i]=x
    now = n-a
    for i in range(b-1):
        now -= times[i]
        for j in range(times[i]):
            ans.append(now+j+1)
print(' '.join(map(str,ans)))

Measured memory_bytes: 104812
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e5 + 5;

string s; 
int lx, rx, ly, ry;


int main() {

    cin >> s;
    for (auto i : s) {
    	if (i == 'S') {
        	ly = -inf;
    		if (ry == 0) ry = -1; 
    	}
    	if (i == 'N') {
    		ry = inf;
    		if (ly == 0) ly = 1;
    	}
    	if (i == 'W') {
    		lx = -inf;
    		if (rx == 0) rx = -1;		
    	}
    	if (i == 'E') {
    		rx = inf;
    		if (lx == 0) lx = 1;
    	}
    }
	if (lx <= 0 && 0 <= rx && ly <= 0 && 0 <= ry) {
		cout << "Yes";
	}
	else cout << "No";
    return 0;
}
    


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
a, b, n = map(int, input().split())
max_score = 0
if n < b:
    max_score = int(a * n / b) - a * (n // b)
elif n == b:
    max_score = max(int(a * n / b) - a * (n // b), int(a * (n-1) / b) - a * ((n-1) // b))
elif a <= b:
    max_score = a - 1
elif a >= b:
    max_score = int(a * (b-1) / b) - a * ((b-1) // b)
else:
    for x in range(1, n + 1):
        score = int(a * x / b) - a * (x // b)
        if max_score < score:
            max_score = score
print(max_score)

Measured memory_bytes: 9160
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

vector<vector<ll>> g;
vector<bool> visited;
ll v1;
ll v2;
deque<ll> p; // path. [v1, ..., v2]

// type: 0 .. front, 1 .. back
void dfs(ll v, ll type) {
  if (type == 0) {
    p.push_front(v);
  } else { // type == 1
    p.push_back(v);
  }

  for (int u : g[v]) {
    if (visited[u]) { continue; }
    // Here, path exist
    visited[u] = true;
    dfs(u, type);
    break; // Here, we need only one edge
  }
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, m;
  cin >> n >> m;
  g.resize(n);
  visited.resize(n);

  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    --a; --b; //0-indexed
    g[a].push_back(b);
    g[b].push_back(a);
  }

  // Here, we start path from 0.
  v1 = 0;
  visited[0] = true;
  v2 = g[0][0];
  visited[v2] = true;
  dfs(v1, 0);
  dfs(v2, 1);

  cout << p.size() << endl;
  rep(i, p.size()) {
    cout << p[i] + 1;
    if (i < p.size()-1) {
      cout << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 7168
#include<stdio.h>
int main()
{
	long long int a,b,x;

	scanf("%lld%lld%lld",&a,&b,&x);

	if(a%x==0)
		printf("%lld",b/x-a/x+1);
	else
		printf("%lld",b/x-a/x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n,k;
    cin>>n>>k;
    vector<pair<ll,ll>>p(n);
    for(int i=0;i<n;i++){
        cin>>p[i].first>>p[i].second;
    }
    sort(p.begin(),p.end());
    int j;
    for(int i=0;i<n;i++){
        k=k-p[i].second;
        if(k<=0){
            j=i;
            break;
        }
    }
    cout<<p[j].first<<endl;

    return 0;
}

Measured memory_bytes: 1792
array = Array.new
gets.to_i.times do
  command = gets.chomp.split
  case command[0]
  when 'insert'
    array.unshift(command[1].to_i)
  when 'delete'
    begin
      array.delete_at(array.index(command[1].to_i))
    rescue
    end
  when 'deleteFirst'
    array.shift
  when 'deleteLast'
    array.pop
  end
end

puts array*' '

Measured memory_bytes: 20700
N = int(input())
p = list(map(int, input().split())) + [0]

counter = 0
seq = 0
for i in range(N + 1):
    if p[i] == i + 1:
        seq += 1
    elif seq != 0:
        counter += (seq + 1) // 2    
        seq = 0
print(counter)


Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d;
    cin>>n>>d;
    ll ans=0;
    for(ll i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        double cdis=x*x + y*y;
        if(sqrt(cdis)<=d)ans++;
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3660
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
#define pii pair<int,int> 
#define mii map<int,int>
#define vi vector<int>
#define umii unordered_map<int,int>
#define mod1 998244353
#define mod2 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define FILL(name,val) memset(name , val , sizeof(name))
#define repo(i,o,e) for(int i = o ; i < e ; i++)
#define rep(n) for(int i = 0 ; i < n ; i++)
const ll sz = 2e5+5;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

const ll inf = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;

void solve(){
    int n , k , x;
    cin >> n >> k;
    rep(n){
        cin >> x;
    }
    int f = k , cnt = 1;
    while(f + k - 1 <= n){
        f += k - 1;
        cnt++;
    }
    if(f < n)cnt++;
    cout << cnt << " ";
    return;
}



int main(){
    FIO;
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000009;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

int N, A[16], x[16][16];
bool y[16][16];

int main() {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        REP(j, A[i]) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    int max = 0;
    REP(state, 1 << N) {
        bool flg = true;
        int sum = 0;
        REP(i, N) {
            int tmp = (state >> i) & 1;
            if (!tmp) {
                continue;
            }
            REP(j, A[i]) {
                if ((y[i][j] ^ (state >> x[i][j]) & 1) & 1) {
                    flg = false;
                    break;
                }
            }
            if (!flg) {
                break;
            }
            sum++;
        }
        if (!flg) {
            continue;
        }
        if (sum > max) {
            max = sum;
        }
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool cmp(char a, char b)
{
	return a>b;
}
int main()
{
	string s, t;
	cin >> s >> t;
	sort (s.begin(), s.end());
	sort (t.begin(), t.end(), cmp);
	if (t>s)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256