akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  string S;
  cin >> S;
  bool n=false,w=false,s=false,e=false;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='N'){
      n=true;
    }
    else if(S.at(i)=='W'){
      w=true;
    }
    else if(S.at(i)=='S'){
      s=true;
    }
    else{
      e=true;
    }
  }
  if((s && n && e && w) || ( s && n && !e && !w) || (!s && !n && e && w)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int n, tmp;
    cin >> n >> tmp;

    vector<string> strings(n);
    rep(i, n) cin >> strings[i];
    sort(all(strings));

    rep(i, n) cout << strings[i];
    cout << endl;
}

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

int main() {
  int n,x,ans;
  cin >> n >> x;
  vector<int> l(n);
  vector<int> d(n+1);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
  }
  ans = 0;
  d.at(0) = 0;
  for(int i=1;i<n+1;i++){
    d.at(i) = d.at(i-1) + l.at(i-1);
    if(d.at(i) <= x){
      ans = i+1;
    }
  }
  cout << ans  << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int h,w,sx,sy,gx,gy;
vvi a(h,vi(w));

int main(){
	cin>>h>>w>>sx>>sy>>gx>>gy;
	sx--,sy--,gx--,gy--;
	a=vvi(h,vi(w));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		char c;
		cin>>c;
		if(c=='#') a[i][j]=-1;
		else a[i][j]=inf;
	}
	int n=0;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(a[i][j]==inf){
		queue<P> q;
		q.push({i,j});
		a[i][j]=n;
		while(!q.empty()){
			P p=q.front();q.pop();
			int x=p.first,y=p.second;
			for(int k=0;k<4;k++){
				int X=x+dx[k],Y=y+dy[k];
				if(X>=0&&X<h&&Y>=0&&Y<w&&a[X][Y]==inf){
					a[X][Y]=n;
					q.push({X,Y});
				}
			}
		}
		n++;
	}
	vvi g(n);
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(a[i][j]>=0){
		for(int k=-2;k<=2;k++) for(int l=-2;l<=2;l++){
			int x=i+k,y=j+l;
			if(x>=0&&x<h&&y>=0&&y<w&&a[x][y]>a[i][j]){
				g[a[i][j]].push_back(a[x][y]);
				g[a[x][y]].push_back(a[i][j]);
			} 
		}
	}
	int s=a[sx][sy],t=a[gx][gy];
	vi d(n,inf);
	d[s]=0;
	queue<int> q;
	q.push(s);
	while(!q.empty()){
		int v=q.front();q.pop();
		for(auto u:g[v]) if(d[u]==inf){
			q.push(u);
			d[u]=d[v]+1;
		}
	}
	cout<<(d[t]==inf?-1:d[t])<<endl;
}

Measured memory_bytes: 20640
#include <stdio.h>
#include <stdlib.h>

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

int main( int argc, char *argv[] )
{
    int s, w;

    scanf( "%d %d", &s, &w );

    if( s > w ) puts( "safe");
    else        puts( "unsafe" );
}


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

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

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    int alice = 0, bob = 0;
    for(int i=0; i<n; i+=2) alice += a[i];
    for(int i=1; i<n; i+=2) bob += a[i];
    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;

int mx;
int d[3000];
int n;
int done[3000] = {};
int ok[3000] = {};
int can(int x){
	if( done[x] ) return 0;
	done[x] = 1;
	if( x == n - 1 ) return 1;
	for(int i = 1 ; i <= mx ; i++){
		int t = min(n-1,x+i);
		t += d[t];
		t = max(0,t);
		if( can(t) ) return 1;
	}
	return 0;
}
int dfs(int x){
	if( !ok[x] ) return 1;
	if( done[x] ) return 0;
	done[x] = 1;
	
	for(int i = 1 ; i <= mx ; i++){
		int t = min(n-1,x+i);
		t += d[t];
		t = max(0,t);
		if( dfs(t) ) return 1;
	}
	return 0;
}
int main(){
	while(cin >> mx && mx){
		for(int i = 0 ; i < 300 ; i++) d[i] = 0;
		for(int i = 0 ; i < 300 ; i++) ok[i] = 1;
		cin >> n;
		n += 2;
		for(int i = 1 ; i < n - 1 ; i++)
			cin >> d[i];
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < 300 ; j++) done[j] = 0;
			ok[i] = can(i);
		}
		for(int j = 0 ; j < 300 ; j++) done[j] = 0;
		cout << (dfs(0)?"NG":"OK") << endl;
		
		
	}
}

Measured memory_bytes: 1168
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[][] = new int [3][3];
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				A[i][j] = sc.nextInt();
			}
		}
		boolean ok[][] = new boolean [3][3];
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				ok[i][j] = true;
				//System.out.println(ok[i][j]);
			}
		}
		int N = sc.nextInt();
		for(int i=0;i<N;i++) {
			int n = sc.nextInt();
			for(int j=0;j<3;j++) {
				for(int k=0;k<3;k++) {
					if(n == A[j][k]) {
						ok[j][k] = false;
					}
				}
			}
		}
		boolean hantei = false;
		for(int i=0;i<3;i++) {
			if(!ok[i][0]&&!ok[i][1]&&!ok[i][2]) {
				hantei = true;
			}
		}
		for(int j=0;j<3;j++) {
			if(!ok[0][j]&&!ok[1][j]&&!ok[2][j]) {
				hantei = true;
			}
		}
		if(!ok[0][0]&&!ok[1][1]&&!ok[2][2]) {
			hantei = true;
		}
		if(!ok[2][0]&&!ok[1][1]&&!ok[0][2]){
			hantei = true;
		}
		if(hantei) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}

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

int main(){
	ld n;
	cin >> n;
	ld temp = n/1.08;
	if(floor(temp)==temp){
		cout << temp;
	}
	else{
		ld temp1=floor(temp);
		ld temp2=ceil(temp);
		if((floor(temp1*1.08))==n){
			cout << temp1;
		}
		else if((floor(temp2*1.08))==n){
			cout << temp2;
		}
		else{
			cout << ":(";
		}
	}

}

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

using namespace std;
typedef long long ll;


const int N=1e5+100;


int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    c=min(c,b-1);
    cout<<a*c/b-a*(c/b)<<endl;
    return 0;
}


Measured memory_bytes: 3592
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (input) {
    //??\????????????????????????????????????
    var inputArray = input.split(' ');
    //??\?????????????????°????????????
    var num = inputArray.map(function(x){
        return parseInt(x);
    });
    //????????????[W,H,x,y,r]
    var W = num[0];
    var H = num[1];
    var x = num[2];
    var y = num[3];
    var r = num[4];
    var answer = 'Yes';
    if((x+r) > W){
        answer = 'No';
    }
    else if((x-r) < 0){
        answer = 'No';
    }
    else if((y+r) > H){
        answer = 'No';
    }
    else if((y-r) < 0){
        answer = 'No';
    }
    console.log(answer);
});

Measured memory_bytes: 15668
"""
#kari1 = 'abaccaba' #Yes
kari1 = 'hthth' #No
in1 = kari1
"""
in1 = input()

mydict = {}

idx1 = 0
for idx1 in range(len(in1)):
    if in1[idx1] in mydict.keys():
        mydict[in1[idx1]] += 1
    else:
        mydict[in1[idx1]] = 1

RC = 'Yes'
for item in mydict.values():
    if item % 2 == 1:
        RC = 'No'
        break

print(RC)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<int> > Graph;
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; }

    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;}
const ll INF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans = a[0];
    rep(i,n-1){
        ans = gcd(a[i+1],ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// Abu Hurayra (HurayraIIT)
// IIT, Jahangirnagar University

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;

typedef long long LL;
typedef long long int int64;
typedef unsigned long long int  uint64;
typedef vector<int> vi; 

#define READ freopen("input.txt", "r", stdin);
#define WRITE freopen("output.txt", "w", stdout);
#define fast_io ios_base::sync_with_stdio(0);  cin.tie(0);
#define sz(a) int((a).size())
#define space " "
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define pi acos(-1.0)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define MOD 1000000007
#define PRECISION(x) cout << fixed << setprecision(x); 
 
 
int main()
{
    fast_io
    string s ;
    cin >> s ;
    int a = s[0]-'0', b = s[1]-'0' , c = s[2]-'0' , d = s[3]-'0' ;

    if(a+b+c+d==7) cout << a << "+" << b << "+" << c << "+" << d << "=7\n";
    else if(a-b-c-d==7) cout <<a<<"-"<<b<<"-"<<c<<"-"<<d<< "=7\n";
    else if(a+b+c-d==7) cout <<a<<"+"<<b<<"+"<<c<<"-"<<d<< "=7\n";
    else if(a+b-c+d==7) cout <<a<<"+"<<b<<"-"<<c<<"+"<<d<< "=7\n";
    else if(a-b+c+d==7) cout <<a<<"-"<<b<<"+"<<c<<"+"<<d<< "=7\n";
    else if(a-b-c+d==7) cout <<a<<"-"<<b<<"-"<<c<<"+"<<d<< "=7\n";
    else if(a-b+c-d==7) cout <<a<<"-"<<b<<"+"<<c<<"-"<<d<< "=7\n";
    else if(a+b-c-d==7) cout <<a<<"+"<<b<<"-"<<c<<"-"<<d<< "=7\n";

    
    
    return 0;
}


 

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    int s,w;
    cin>>s>>w;
    if(w>=s){
        out("unsafe");
    }else{
        out("safe");
    }

}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(true){
        cin >>H>>W;
        if(H==0&&W==0)break;
        for(int i=0;i<W;i++){
            printf("#");
        }
        printf("\n");
        for(int j=1;j<(H-1);j++){
            for(int k=0;k<W;k++){
                if(k==0||k==(W-1)){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        for(int l=0;l<W;l++){
            printf("#");
        }
        printf("\n");
        printf("\n");
    }
}



Measured memory_bytes: 3044
#include <stdio.h>
int main(){
    int i, k, H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }else{
        for(i = 0;i <H; i++){
        for(k=0; k<W; k++){
            printf("#");
        }
            printf("\n");
        }
             printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pa = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    vl D(N);
    rep(i, N) D[i] = A[i] - B[i];
    sort(all(D), greater<ll>());

    vl mi;
    ll ans = 0, sum = 0;
    rep(i, N) if (D[i] < 0) {
        ans++;
        mi.eb(-D[i]);
        sum += -D[i];
    }
    rep(i, N) {
        if (sum <= 0) break;
        sum -= D[i];
        ans++;
    }
    if (sum > 0) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3196
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, L: "List[int]", R: "List[int]"):
    lower = 0
    upper = 10000000000
    for i in range(M):
        lower = max(lower, L[i])
        upper = min(upper, R[i])
    if upper < lower:
        print(0)
    else:
        print(upper - lower + 1)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]" 
    R = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        L[i] = int(next(tokens))
        R[i] = int(next(tokens))
    solve(N, M, L, R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10868
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n+1, 0);
  a.at(0) = 1;
  rep(i, k) {
    int d;
    cin >> d;
    rep(i, d) {
      int sunuke;
      cin >> sunuke;
      if (a.at(sunuke) == 0) {
        a.at(sunuke) = 1;
      }
    }
  }
  int count = 0;
  rep(i, n+1) {
    if (a.at(i) == 0) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3568
S = gets.chomp.to_s
puts '7' if S == 'SUN'
puts '6' if S == 'MON'
puts '5' if S == 'TUE'
puts '4' if S == 'WED'
puts '3' if S == 'THU'
puts '2' if S == 'FRI'
puts '1' if S == 'SAT'

Measured memory_bytes: 1788
//
//  main.cpp
//  atCoder
//
//  Created by 佐々木勇星 on 2019/07/23.
//  Copyright © 2019 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <regex>


int main(void) {

    using namespace std;

    string S;
    string T;
    
    int count = 0;
    char chs;
    char cht;
    
        cin >> S;
        cin >> T;
    
    
    for(int i=0; i<3; i++){
         chs = S[i];
        cht = T[i];
        
        if(chs == cht) count++;
        
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = sorted(list(map(int, input().split()))) 

ans = 0

import bisect

for a in range(N):
    for b in range(a):
        A=L[a]
        B=L[b]
        c=bisect.bisect_left(L, A+B)
        ans+=c-a-1

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(a,x,y) for(int i=(x);i<=(y);++i){cout<<a[i]<<" ";}cout<<endl;
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infd DBL_MAX
#define infl 10e17
#define mod 1000000007ll
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v ) {
    os << "[";
    typename multiset< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}
#define pr(x) cerr << #x << " = " << x << endl;

int main()
{
    string s;
    cin>>s;
    int len=s.length();
    if(s[len-1]=='s')
    {
        s+="es";
    }
    else
    {
        s+="s";
    }
    cout<<s;
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(void){
	string  y;
	int a = 0;
	cin>>y;
	string  x;
	while(true){
		cin>>x;
		if(x == "END_OF_TEXT")break;
		for(int i = 0;i<x.size();i++){
		x.at(i) = (char)tolower(x.at(i));
		}
		
		if(x == y)a++;

	}
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 3164
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <numeric>

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);

  int sum = std::accumulate(a.begin(), a.end(), 0);
  int res = 0;
  for (size_t i = 0; i < n; ++i) {
    if (int(a[i] * n) <= sum) ++res;
  }
  printf("%d\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2648
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int N,T;cin>>N>>T;
  int a[N];
  rep(i,N){
    cin >> a[i];
  }
  int kekka = 0;
  rep(i,N){
    if(i != N-1){
      if(a[i+1] - a[i] < T)kekka+=(a[i+1]-a[i]);
      else kekka+=T;
    }else kekka+=T;
  }
  cout << kekka << endl;
}

Measured memory_bytes: 1024
N = int(input())
A = [int(input()) for _ in range(N)]
i = 0
done = {a - 1: False for a in A}
num = 0
while True:
    i = A[i] - 1
    num += 1
    if i == 1:
        print(num)
        exit()
    if done[i]:
        print(-1)
        exit()
    done[i] = True


Measured memory_bytes: 19084
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, K, A[200001], i, count[200001], kind, ans=0;

    cin >> N >> K;

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

        count[A[i]]++;
    }

    sort(count+1, count+N+1);

    i = 1;

    while(count[i] == 0){
        i++;
    }

    kind = N-(i-1);

    if(kind <= K){
        cout << 0 << endl;
    }

    else{
        while(kind > K){
            ans += count[i];
            i++;

            kind--;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3456
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var p = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	sort.Ints(p)
	sum := 0
	for i := 0; i < k; i++ {
		sum += p[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1888
'use strict';

function main(arg) {
    const N     = Number(arg.split("\n")[0]);
    const words = (arg.split("\n"));
    const memo  = new Set();
    
    words.shift();
    let lastLetter = words[0].slice(0, 1);

    for(let i=0; i<N; i++) {
        if(lastLetter !== words[i].slice(0, 1)) {
            console.log('No');
            return;
        }
        
        if(memo.has(words[i])) {
            console.log('No');
            return;
        }

        lastLetter = words[i].slice(-1);
        memo.add(words[i]);
    }
    
    console.log('Yes');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main() {
	string s;
	cin >> s;
	map<char, string> m;
	m['S'] = "Cloudy";
	m['C'] = "Rainy";
	m['R'] = "Sunny";
	cout << m[s[0]] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define ALL(a)              a.begin(), a.end()
#define ALLN(a, n)          (a, a+n)
#define MAX                 10000007
#define MIN                 -10000007



              
int main()
{
  ios::sync_with_stdio(0);
    cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
      
    int t;
    t=1;
     //  cin>>t;
    while(t--){
           int n,c=0;
            cin>>n;
            ll a[n];
            REP(i,0,n-1) cin>>a[i];  
            sort(a,a+n);
            REP(i,0,n-1){
                REP(j,i+1,n-1){
                    REP(k,j+1,n-1){
                        //if(i!=j&&j!=k&&i!=k){
                            if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]){
                                c++;
                            } 
                        //}
                    }
                }
            }
            cout<<c;

           /* string s;
            cin>>s;
            int maxx=0,n=s.size();
            int j=0;
            REP(i,0,2){
                if(s[i]=='R'){
                    j=i;
                    while(s[i]=='R'){
                        i++;
                        if(i==n) break;
                    }
                    maxx=max(maxx,i-j);
                    j=i;
                }
            }
            cout<<maxx;
*/
             }
             cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


Measured memory_bytes: 3808
#include <stdio.h>

int main(void)
{
	int x[10000],i,a=1;
	
	scanf("%d",&x[0]);
	while(x[a-1]!=0 ){
		scanf("%d",&x[a]);
		a++;
	}
	for(i=0 ; i<a-1 ; i++)
		printf("Case %d: %d\n",i+1,x[i]);
	
	return 0;
}

Measured memory_bytes: 1832
kw = input()
n_of_kw = 0

while True:
    sentence = input().split(" ")
   
    if sentence[0] == "END_OF_TEXT":
        break
    else:
        sentence2 = []
        for i in sentence:
            sentence2.append(i.lower())
        n_of_kw += sentence2.count(kw)
      
print(n_of_kw)


Measured memory_bytes: 5564
#include <stdio.h>
#define N 1000


int main(){
	int a[N][N];
	int n,k,u,i,j,v;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&u);
		scanf("%d",&k);
		for(j=0;j<k;j++){
			scanf("%d",&v);
			a[u-1][v-1] = 1;
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			printf("%d",a[i][j]);
			if(j!=n-1)printf(" ");
		}
		printf("\n");
	}
return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

ll dp[50][500][500];

long long gcd(long long a, long long b){
	while(a != b){
		if(a > b) a = a-b;
		else b = b - a;
	}
	return a;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n, ma, mb;
	cin >> n >> ma >> mb;

	vector<int> a;
	vector<int> b;
	vector<int> c;
	a.pb(0);
	b.pb(0);
	c.pb(0);
	for(int i=0; i<n; i++){
		int ta, tb, tc;
		cin >> ta >> tb >> tc;
		a.pb(ta);
		b.pb(tb);
		c.pb(tc);
	}

	for(int i=0; i<=n; i++){
		for(int j=0; j<=400; j++){
			for(int k=0; k<=400; k++){
				dp[i][j][k] = INF;
			}
		}
	}

	dp[0][0][0] = 0;
	for(int i=1; i<=n; i++){
		for(int j=0; j<=400; j++){
			for(int k=0; k<=400; k++){
				if(j-a[i] >= 0 && k-b[i] >= 0){
					dp[i][j][k] = min(dp[i-1][j][k], dp[i-1][j-a[i]][k-b[i]] + c[i]);
				}else{
					dp[i][j][k] = dp[i-1][j][k];

				}
			}
		}

		/*
		for(int j=0; j<=20; j++){
			for(int k=0; k<=20; k++){
				if(dp[i][j][k] != INF){
					printf("%2d ", dp[i][j][k]);
				}else{
					printf("%IN ");
				}
			}
			puts("");
		}
		puts("");
		*/
	}


	ll ans = INF;
	for(int j=1; j<=400; j++){
		for(int k=1; k<=400; k++){
			if(j/gcd(j, k) == ma && k/gcd(j,k) == mb){
				ans = min(ans, dp[n][j][k]);
			}
		}
	}
	if(ans == INF){
		puts("-1");
	}else{
		cout << ans << endl;
	}

	
	return 0;
}


Measured memory_bytes: 79744
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
b=c
d=0
for i in range(n):
  for j in range(m):
    b+=(a[i][j]*B[j])
  if b>0:
    d+=1
  b=c
print(d)

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

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

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] pointsx = br.readLine().split(" ");
        String[] pointsy = br.readLine().split(" ");
        int i;

        int[] x = new int[n];
        int[] y = new int[n];
        for (i = 0; i < n; i++) {
            x[i] = Integer.parseInt(pointsx[i]);
            y[i] = Integer.parseInt(pointsy[i]);
        }

        for (i = 1; i <= 3; i++) {
            System.out.println(calcDistance(x, y, i));
        }

        double chebyshev = 0;
        double abs;
        for (i = 0; i < n; i++) {
            if (chebyshev < (abs = Math.abs(x[i] - y[i]))) {
                chebyshev = abs;
            }
        }
        System.out.println(chebyshev);

    }

    public static double calcDistance(int[] x, int[] y, int p) {
        double D = 0;
        for (int i = 0; i < x.length; i++) {
            D += Math.pow(Math.abs(x[i] - y[i]), p);
        }
        return Math.pow(D, (double) 1/p);
    }
}

Measured memory_bytes: 24388
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int i;
   char a[3];
   scanf("%s",a);
   int j=0,k=0,l=0;
   for(i=0;i<3;i++)
   {
       if(a[i]=='a')
        j=1;
       if(a[i]=='b')
        k=1;
       if(a[i]=='c')
        l=1;
   }
   if(j==1&&k==1&&l==1)
    printf("Yes\n");
   else
    printf("No\n");
    return 0;
}


Measured memory_bytes: 128
def check(string2):
	N = len(string2)
	rev = string2[::-1]
	for i in range((N//2)+1):
		if(rev[i]!=string2[i]):
			return False
	return True


string = input()
n = len(string)
n-=1
str1 = string[0:int((n)/2)]
# print(str1)
str2 = string[int((n)/2)+1:n+1]
# print(str2)
if check(str1) and check(str2) and check(string):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 38336
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;


int main(){

 int t;
 int ac=0,wa=0,tle=0,re=0;
 cin>>t;

 while(t--){

    string s;
    cin>>s;

    if(s == "AC")
        ac++;
    else if(s == "WA")
        wa++;
    else if(s == "TLE")
        tle++;
    else if(s == "RE")
        re++;
 }

  cout<<"AC"<<" x "<<ac<<endl;
  cout<<"WA"<<" x "<<wa<<endl;
  cout<<"TLE"<<" x "<<tle<<endl;
  cout<<"RE"<<" x "<<re<<endl;

 return 0;
}


Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main(void) {
	int y, m, d, n;
	int res;
	int i, j;

	cin >> n;
	for(i = 0; i < n; i++) {
		cin >> y >> m >> d;
		res = -d+1;
		for(j = m; j <= 10; j++) {
			if(y%3 != 0 && j%2 == 0) {
				res += 19;
			} else {
				res += 20;
			}
		}
		for(j = y+1; j < 1000; j++) {
			if(j%3 == 0) {
				res += 200;
			} else {
				res += 195;
			}
		}
		cout << res << endl;
	}

	return 0;
}

			

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

int main(void) {
    char S[3], tmp;
    int flag = 0, i;

    cin >> S;

    for(i=1, tmp=S[0]; i<3; i++){
        if(tmp!=S[i]){
            flag = 1;
            break;
        }
        tmp = S[i];
    }

    if(flag)    cout << "Yes";
    else        cout << "No";

    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans = 0;
	ans = min(a,k);
	k -= ans;
	k -= min(k,b);
	ans -= min(k,c);
	cout<<ans;
	
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,pair<ll,ll>> pii;
typedef pair<ll,ll> pi;
typedef vector<ll> vl;

#define matrix vector<vector<ll>>
#define llmax LLONG_MAX
#define llmin LLONG_MIN
#define rep(i,n) for(ll (i)=0;(i)<n;++(i))
#define crep(i,m,n) for(ll (i)=m;(i)<n;++(i))
#define zero(a) memset((a),0,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)));
#define sq(a) ((a)*(a))
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define ff first
#define ss second

ll global=0;

// return nCr value
long long C(int n, int r) {
	if(r>n) return 0;
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;
    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}

// return whether number is prime or not
vector<ll> sieve(ll n){
    vector<ll> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return is_prime;
}


void test_case();
int main(){
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    for(ll T=0;T<t;T++){
        test_case();
    }
    //**************************************************************************//
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

void self_min(ll &a, ll b){
    a = min(a,b);
}

void test_case(){
    ll n,W,sum=0;cin>>n>>W;
    std::vector<ll>val(n), wt(n);
    rep(i,n)cin>>wt[i]>>val[i];
    rep(i,n)sum+=val[i];
    std::vector<ll> dp(sum+1,mod);
    // dp[i] -- minimum total weight for total value exactly i
    dp[0] = 0;
    rep(i,n){
        for(ll val_already = sum-val[i]; val_already>=0;--val_already){
            self_min(dp[val_already+val[i]], dp[val_already]+wt[i]);
            // cout<<"-1 ";
        }
    }
    ll ans=0;
    rep(i,sum+1){
        // cout<<dp[i]<<" ";
        if(dp[i]<=W)
            ans = max(ans, (ll)i);
    }
    cout<<ans;
}


Measured memory_bytes: 3956
n,m=map(int,input().split())
a=[]
for i in range(n):
	k=list(map(int,input().split()))
	a.append(k)
q=[]
for i in range(n):
	for j in range(m):
		if a[i][j]%2!=0:
			a[i][j]-=1
			if j!=m-1:
				a[i][j+1]+=1
				q.append([i+1,j+1,i+1,j+1+1])
			else:
				try:
					a[i+1][j]+=1
					q.append([i+1,j+1,i+1+1,j+1])
				except:
					print(len(q))
					for ii in range(len(q)):
						print(*q[ii])
					exit()
print(len(q))
for i in range(len(q)):
	print(*q[i])


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



#if 0
const int MOD = ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;

const int MAXN = 512;

int mat[MAXN + 1][MAXN + 1];

void solve(int l, int r, int cnt) {
    if(l == r) {
        return ;
    }

    int mid = (l + r) / 2;
    solve(l, mid, cnt + 1);
    solve(mid + 1, r, cnt + 1);

    int i, j;
    for(i = l; i <= mid; i++) {
        for(j = mid + 1; j <= r; j++) {
            mat[i][j] = cnt;
        }
    }
}

int main() {
#if 0
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    int i, j, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;
    int aux = n;
    while((n & (n - 1)) > 0) {
        n++;
    }
    solve(1, n, 1);
    n = aux;
    for(i = 1; i <= n; i++) {
        for(j = i + 1; j <= n; j++) {
            cout << mat[i][j] << " ";
        }
        cout << "\n";
    }

    return 0;
}



Measured memory_bytes: 1536
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int  n = Integer.parseInt(sc.next());
        int  k = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for(int i=0;i<n;i++){
            h[i] = Integer.parseInt(sc.next());
        }
        int cnt = 0;
        for (int i=0;i<n;i++) {
            if(h[i]>=k)cnt++;
        }
        System.out.println(cnt);
        
    }
    
    private static void sort(int[] d, int left, int right){
        if(left>=right){return;}
        int p = d[(left+right)/2];
        int l=left, r=right;
        int tmp;
        while(l<=r){
            while(d[l]>p){l++;}
            while(d[r]<p){r--;}
            if(l<=r){
                tmp=d[l];
                d[l] = d[r];
                d[r] = tmp;
                l++; r--;
            }
        }
        sort(d, left, r);
        sort(d, l, right);
    }
}

Measured memory_bytes: 48464
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
vector<int> v[MN+5];
int mark[MN+5],q[MN+5],n,top,num[5];
int main()
{
    n=read();
    for(int i=1;i<n;++i)
    {
        int a=read(),b=read();
        v[a].push_back(b);
        v[b].push_back(a);
    }
    q[top=mark[1]=1]=1;q[top=mark[n]=2]=n;
    for(int i=1;i<=top;++i)
    {
        ++num[mark[q[i]]];
        for(int j=0;j<v[q[i]].size();++j)
            if(!mark[v[q[i]][j]]) mark[q[++top]=v[q[i]][j]]=mark[q[i]];
    }
    puts(num[1]>num[2]?"Fennec":"Snuke");
    return 0;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }



int main()
{
	int64_t ans, a, b, c, d;

	cin >> a >> b >> c >> d;
	ans = a * c;
	ans = max(ans, b * c);
	ans = max(ans, a * d);
	ans = max(ans, b * d);
	if ((a < 0 && 0 < b) || (c < 0 && 0 < d))
		ans = max(ans, (int64_t)0);
	cout << ans << endl;
}

Measured memory_bytes: 3708
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void)
{
	 long long a,b,t,i;
	 long long ans;
	 int tamp;
	 while(scanf("%lld %lld",&a,&b)!=EOF)
	 {
	 	tamp=1;
		 if(a%b==0)
	 	{
	 		printf("-1\n");
	 		continue;
		 }
		for(i=2;ans<=pow(10,18);i++)
		{
			ans=i*a;
			if(ans%b!=0)
			{
				printf("%lld\n",ans);
				tamp=0;
				break;
			}
			
		}
		if(tamp==1)
		printf("-1\n");
		
	  } 
} 

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<stdio.h>
using namespace std;
int main(){
	int sum=0;
	string str;
	while(1){
		getline(cin,str);
		for(int i=0;i<str.size();i++){
			str[i]-='0';
				sum+=str[i];
		}
		if(str[0]==0)break;
		cout<<sum<<endl;
		sum=0;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    int n;
    int a[10005];
    cin >> n;
    cinf(n,a);
    sort(a,a+n,greater<int>());
    int al=0, bo=0;
    FOR(i,n){
        if(i&1) bo+=a[i];
        else al+=a[i];
    }
    cout << al - bo fin;
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;




Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<fstream>
#include<typeinfo>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define repi(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j, a, b) for (ll j = a; j < b;j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >
#define mod 1000000007
#define lim 100001
 
using namespace std;
ll factorial(ll n){return (n==1 || n==0) ? 1: n * factorial(n - 1); }
int max3(int a,int b,int c){ return max(a, max(c, b));}
int gcd(int a,int b){if(a==0){return b;}else{return gcd(b % a, a);}}
ll power(ll a, ll n){if(n==1) return a; else if(n==0) return 1; else{ ll r = power(a, n / 2); if(n%2==0) return r * r; else return r * a * r;}}
ll nCr(ll n, ll r) { return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
void dfs(vector< vector<int > >& v,vi& check,int start){check[start - 1] = 1;repj(j, 0, v[start-1].size()){if(!check[v[start-1][j]-1]){dfs(v, check, v[start - 1][j]);}}}
bool isPrime(ll n) { if (n <= 1) return false;if (n <= 3)return true; if (n % 2 == 0 || n % 3 == 0)return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
//works under 2 till 1e12
 
//int i, j;
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   char a;
   cin>>a;
   int c = a;
   if(c<95){
       cout<<"A";
   }
   else cout<<"a";
   return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int m, n;
	while (cin >> m >> n, m)
	{
		vector<bool> ok(1e7);
		int cnt = 0;
		int p = m;
		while (cnt < n)
		{
			cnt++;
			while (ok[p]) p++;
			ok[p] = true;
			REP(i, 1e7)
			{
				if (p * i >= 1e7) break;
				ok[p*i] = true;
			}
		}
		FOR(i, m, 1e7)
		{
			if (!ok[i])
			{
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

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

long long int modd(long long int N){
  	N %= 998244353;
  	if (N < 0) N += 998244353;
  	return N;
}

int main(){
  	long long int A, B, C, D;
  	cin >> A >> B >> C >> D;
  	long long int dp[C][D];
  	for (int i = 0; i < C; i++){
      	for (int j = 0; j < D; j++){
          	if (i < A && j < B) dp[i][j] = 1;
          	else dp[i][j] = 0;
        }
    }
  
  	for (int i = A - 1; i < C; i++){
      	for (int j = B - 1; j < D; j++){
          	if (i == A - 1 && j == B - 1) continue;
          	if (i == A - 1){
              	dp[i][j] = modd(dp[i][j - 1] * A);
            }
          	if (j == B - 1){
              	dp[i][j] = modd(dp[i - 1][j] * B);
            }
          	if (i > A - 1 && j > B - 1){
              	dp[i][j] = modd(dp[i - 1][j] * (j + 1) + dp[i][j - 1] * (i + 1) - dp[i - 1][j - 1] * i * j);
            }
        }
    }
  
  	cout << dp[C - 1][D - 1] << endl;
}

Measured memory_bytes: 73896
#include <stdio.h>

int main(void) {
    int a;
    int b;
    int c;
    scanf("%d %d %d\n",&a, &b, &c);

    if(a < b && b < c) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2032
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

N, K = map(int, raw_input().split())
DP = [[0] * (K + 1) for i in range(K + 1)]
bias = 0

for i in range(N):
    x, y, c = raw_input().split()
    x, y, c = int(x), int(y), (c == 'W')
    if (x / K + y / K + c) % 2 == 0:
        DP[y % K + 1][x % K + 1] += 1
    else:
        DP[y % K + 1][x % K + 1] -= 1
        bias += 1

for i in range(K):
    for j in range(K + 1):
        DP[i + 1][j] += DP[i][j]

for i in range(K + 1):
    for j in range(K):
        DP[i][j + 1] += DP[i][j]

ans = 0

for i in range(K + 1):
    for j in range(K + 1):
        S1 = DP[i][j] * 2 - DP[i][K] - DP[K][j] + DP[K][K]
        S2 = DP[i][K] + DP[K][j] - DP[i][j] * 2
        ans = max(ans, S1, S2)

print ans + bias

Measured memory_bytes: 23272
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a[5],r=0,i,j,k,h[]={0};
     string s;
     cin>>s;
     if(s[0]==s[1] && s[1]==s[2])
     cout<<"No"<<endl;
     else
         cout<<"Yes"<<endl;
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <regex>
using namespace std;

int main(){
  int x;
  string s;
  cin >> x >> s;
  
  char k3 = '0';
  char k2 = '0';
  char k1 = '0';
  size_t p3,p2,p1;
  
  int count = 0;
  //cout << SIZE_MAX;
  while(k3 <= '9'){
    while(k2 <= '9'){
      while(k1 <= '9'){
        p3 = s.find(k3);
        if(p3 != SIZE_MAX){
          p2 = s.find(k2, p3+1);
          if(p2 != SIZE_MAX){
            //cout << s.find(k1, p2) <<" ";
            if(s.find(k1, p2+1) != SIZE_MAX){
              count++;
            }
          }
        }
        k1++;
      }
      k1 = '0';
      k2++;
    }
    k1 = '0';
    k2 = '0';
    k3++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256