akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int a, b, c;
    cin >> a >> b >> c;
    
    cout << min(c, b/a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[51],b[51],c,d,n,m,x,y,z,h,w,k,sum,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;

int main(void){
    cin>>n>>m;
    VL v;
    rep(i,1,sqrt(m)+10){
        if(m%i==0){v.pb(i);v.pb(m/i);}
    }
    //rep(i,v.size())p(v[i]);
    sort(all(v));
    for(int i: v){
        if(m%i==0 && m/i>=n){
            ma=max(ma,(ll)i);
        }
    }
    p(ma);
    return 0;
}


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

using namespace std;

int main() {
   

   int X, Y;
   cin>>X>>Y;
   int a,b;
   b=(Y-2*X)/2;
   a=X-b;
   if(b>=0 && (Y-2*X)%2==0 && a>=0){
       cout<<"Yes";
   }
   else {
       cout<<"No";
   }
   
}

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

int a[100003];

int main()
{
    int N;
    cin >> N;
    while (N--)
    {
        int t;
        cin >> t;
        a[t]++;
        a[t + 1]++;
        a[t + 2]++;
    }


    cout << *max_element(a + 2, a + 100000) << endl;
    return 0;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 25, M = 1e6 + 25, oo = 1e9, mod = 1e9 + 7;
const long long OO = 1e18+25;

int n, a[N];
long  long  mem[N][N][2];

long long dp(int i=0, int j=n-1, int turn=1)
{
    if(i > j) return 0;
    long long &ret = mem[i][j][(turn==1)];
    if(ret != 0) return ret;
    if(turn==1)return ret = max(dp(i+1,j, turn*-1)+(turn*a[i]), dp(i, j-1, turn*-1)+(a[j]*turn));
    return ret = min(dp(i+1,j, turn*-1)+(turn*a[i]), dp(i, j-1, turn*-1)+(a[j]*turn));
}

int main()
{
    //memset(mem, -1, sizeof mem);
    scanf("%d",&n);
    for(int i=0; i<n; i++) scanf("%d",a+i);
    printf("%lld",dp());
    return 0;
}

Measured memory_bytes: 141952
#include <bits/stdc++.h>
#define endl        '\n'
#define pi          2*acos(0.0)
#define pb(a)       push_back(a)
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define mod         1000000007
#define inf         1000000000000000001
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b) 
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 100003

using namespace std;

vector<int> primes;
bitset<MAX> marked;

void sieve(int n) {
    for (int i = 3; i * i <= n; i += 2) {
        if(!marked[i]) {
            for (int j = i * i; j <= n; j += 2 * i) {
                marked[j] = true;
            }
        }
    }
    primes.push_back(2);
    for (int i = 3; i <= n; i += 2) {
        if(!marked[i])
            primes.push_back(i);
    }
}

bool isPrime(int n) {
    if(n < 2) return false;
    if(n == 2) return true;
    if(n % 2 == 0) return false;
    return !marked[n];
}

int main()
{
    //freopen("/home/sohel/Documents/my_codes/out.txt", "wt", stdout);
    unsyncIO;
    sieve(100003);
    int n;
    cin >> n;
    int t;
    t = n;
    while(!isPrime(t))
        t++;
    cout << t << endl;

    return 0;
}

Measured memory_bytes: 3788
//Name: Fukushimaken
//Level: 2
//Category: シミュレーション
//Note: 

/**
 * 問題文の通りにシミュレーションする。
 * グループの到着と、食事の終了イベントをpriority_queueに突っ込んで取り出すようにする。
 * 到着したグループは別途queueに突っ込み、席に空きができたら埋めていくようにする。
 *
 * 入力が小さいので、特に効率のよいデータ構造を使わなくても間に合う。
 * オーダーは O(NW log N)。
 * ただしNはグループ数で、N=100。Wは座席の幅で、W=17。
 */
#include <iostream>
#include <queue>

using namespace std;

struct Event {
    enum {
        ARRIVAL,
        FINISH
    } type;
    int t;
    int idx;

    bool operator <(const Event &e) const {
        return t > e.t;
    }
};

int gsize(int n) {
    return (n % 5 == 1 ? 5 : 2);
}

bool solve(bool first) {
    vector<int> res(100, -1);
    priority_queue<Event> eventq;
    for(int i = 0; i < 100; ++i) {
        eventq.push(Event{Event::ARRIVAL, i*5, i});
    }
    queue<int> q;
    vector<int> seats(17, -1);
    while(!eventq.empty()) {
        const int curt = eventq.top().t;
        while(!eventq.empty() && eventq.top().t == curt) {
            const Event e = eventq.top();
            eventq.pop();
            if(e.type == Event::ARRIVAL) {
                q.push(e.idx);
            } else {
                for(int i = 0; i < 17; ++i) {
                    if(seats[i] == e.idx) seats[i] = -1;
                }
            }
        }
        while(!q.empty()) {
            const int idx = q.front();
            const int s = gsize(idx);
            int acc = 0;
            int pos = -1;
            for(int i = 0; i < 17; ++i) {
                if(seats[i] == -1) {
                    ++acc;
                } else {
                    acc = 0;
                }
                if(acc == s) {
                    pos = i - s + 1;
                    break;
                }
            }
            if(pos == -1) break;
            for(int i = 0; i < s; ++i) {
                seats[pos+i] = idx;
            }
            res[idx] = curt - idx*5;
            eventq.push(Event{Event::FINISH, curt + 17*(idx%2) + 3*(idx%3) + 19, idx});
            q.pop();
            /*
               for(int i = 0; i < 17; ++i) {
               if(seats[i] == -1) cout << '-';
               else cout << seats[i]%10;
               }
               cout << endl;
               */
        }
    }

    int N;
    while(cin >> N) {
        cout << res[N] << endl;
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1220
n,k = map(int,input().split())
mod = 10**9+7
from itertools import accumulate
N = list(range(n+1))
N_acc = [0]+list(accumulate(N))
ans = 0
for i in range(k,n+2):
    ans += ((N_acc[-1]-N_acc[-i-1])-N_acc[i]+1)%mod
print(ans%mod)

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

using namespace std;

const int MOD = 1e9 + 7;

char s[1005][1005];
long long dp[1005][1005];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);

    for (int i = 0; i < n; i++) scanf("%s", s[i]);

    dp[0][0] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '#') continue;
            if (i - 1 >= 0 && s[i - 1][j] == '.') dp[i][j] += dp[i - 1][j];
            if (j - 1 >= 0 && s[i][j - 1] == '.') dp[i][j] += dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    }

    printf("%lld\n", dp[n - 1][m - 1]);
}


Measured memory_bytes: 9088
#include <stdio.h>
int main ()
{
	int n, paid=0;
	scanf ("%d", &n);
	int value[n], price[n];
	for (int j=0; j<n; j++)
	{
		scanf ("%d", &value[j]);
	}	
	for (int k=0; k<n; k++)
	{
		scanf ("%d", &price[k]);
	}
	for (int i=0; i<n; i++)
	{
		if (value[i]>price[i])
		paid+=(value[i]-price[i]);
	}
	printf ("%d", paid);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int suf[105];
int n;
string s[105];
int t[105];
string o;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>s[i]>>t[i];
    for(int i=n;i>=1;i--) suf[i]=suf[i+1]+t[i];
    cin>>o;
    for(int i=1;i<=n;i++)
        if(s[i]==o){
            cout<<suf[i+1]<<endl;
        }
    return 0;
}

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

const int MAXN = 160;
typedef long long LL;
int mod;
void reduce(int & x) { x += x >> 31 & mod; }
int solve1(int n, int K) {
	static int f[MAXN][MAXN];
	memset(f, 0, sizeof f);
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		memcpy(f[i] + 1, f[i - 1], K << 2);
		for (int j = 0; j < K; ++j)
			f[i][0] = std::accumulate(f[i - 1], f[i], 0ll) % mod;
	}
	return std::accumulate(f[n], f[n + 1], 0ll) % mod;
}
int n, K;
struct status {
	int l, r, ll, rl;
	bool operator < (const status & b) const {
		if (l != b.l) return l < b.l;
		if (r != b.r) return r < b.r;
		if (ll != b.ll) return ll < b.ll;
		return rl < b.rl;
	}
} ;
std::map<status, int> dp[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> K >> mod;
	int ans = 0;
	if (K % 2 == 0)
		ans = (LL) solve1(n >> 1, K >> 1) * solve1(n - (n >> 1), K >> 1) % mod;
	else {
		int now = 1, lst = 0;
		dp[now][(status) {0, 0, n + 1, n + 1}] = 1;
		for (int i = 0; i < n; ++i) {
			std::swap(now, lst); dp[now].clear();
			for (auto j : dp[lst]) {
				auto t = j.first; int v = j.second;
				if (i & 1) {
					reduce(dp[now][(status) {0, t.r, n + 1, t.rl}] += v - mod);
					if (t.ll > i + 1) {
						int tl = t.rl;
						if (i + 2 - 2 * t.r + K <= i + 1)
							tl = std::min(tl, i + 1 - 2 * t.l + K);
						reduce(dp[now][(status) {t.l + 1, t.r, t.ll, tl}] += v - mod);
					}
				} else {
					reduce(dp[now][(status) {t.l, 0, t.ll, n + 1}] += v - mod);
					if (t.rl > i + 1) {
						int tl = t.ll;
						if (i + 2 - 2 * t.l + K <= i + 1)
							tl = std::min(tl, i + 1 - 2 * t.r + K);
						reduce(dp[now][(status) {t.l, t.r + 1, tl, t.rl}] += v - mod);
					}
				}
			}
		}
		for (auto t : dp[now]) reduce(ans += t.second - mod);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int num;
  cin >> n;
  vector<int> ans(n + 1,0);

    for(int x = 1; x< 100;x++){
      for(int y = 1;y < 100;y++){
        for(int z = 1;z < 100;z++){
          num = x * x + y * y + z * z + x * y + y * z + z * x;
          if(num <= 10000)ans[num]++;
        }
      }
    }
    for(int i = 1;i <= n;i++){
      cout << ans[i] << endl;
    }
  }

Measured memory_bytes: 3664
#計算量解析
#O(NlogN)
class Method1:
  def __init__(self, N):
    self.N = N
    self.memo = [-1] * 110000
  
  def rec(self,n):
    if n == 0:
      return 0
    if self.memo[n] != -1:
      return self.memo[n]
    res = n
    cnt = 0
    while 6 ** cnt <= n:
      res = min(res, self.rec(n - 6 ** cnt) + 1)
      cnt += 1
    cnt = 0
    while 9 ** cnt <= n:
      res = min(res, self.rec(n - 9 ** cnt) + 1)
      cnt += 1
    self.memo[n] = res
    return res

  def ans(self,):
    print(self.rec(self.N))
    
#配るDP   
class Method2():
  def __init__(self, N):
    self.N = N
    self.dp = [N] * 110000
  def ans(self, ):
    self.dp[0] = 0
    for n in range(1,self.N + 1):
      cnt = 0
      while 6 ** cnt <= n:
        self.dp[n] = min(self.dp[n], self.dp[n - 6 ** cnt] + 1)
        cnt += 1
      cnt = 0
      while 9 ** cnt <= n:
        self.dp[n] = min(self.dp[n], self.dp[n - 9 ** cnt] + 1)
        cnt += 1
    print(self.dp[self.N])

#
class Method3():
  def __init__(self, N):
    self.N = N
    self.dp = [N] * 110000
    
if __name__ == '__main__':
  inputN = int(input())
  #method = Method1(inputN)
  method = Method2(inputN)
  method.ans()
    


Measured memory_bytes: 3956
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N, K;
    cin >> N >> K;
    ll R, S, P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    vector<ll> score = {R, S, P};
    auto win = make_vec_nd(false, 3, 3);
    win[0][1] = true;
    win[1][2] = true;
    win[2][0] = true;
    unordered_map<char, ll> hand_idx;
    hand_idx['r'] = 0;
    hand_idx['s'] = 1;
    hand_idx['p'] = 2;
    vector<vector<ll>> Ts(K);
    rep(i,0,T.size()) {
        Ts[i%K].push_back(hand_idx[T[i]]);
    }
    ll ans = 0;
    rep(k,0,K) {
        if (Ts[k].size() == 0) {
            continue;
        }
        auto dp = make_vec_nd((ll)0, Ts[k].size(), 3);
        rep(h,0,3) {
            if (win[h][Ts[k][0]]) {
                dp[0][h] = score[h];
            }
        }
        rep(i,1,Ts[k].size()) {
            rep(h,0,3) {
                rep(h_pre,0,3) {
                    if (h_pre == h) {
                        continue;
                    }
                    dp[i][h] = max(dp[i][h], dp[i-1][h_pre]);
                }
                if (win[h][Ts[k][i]]) {
                    dp[i][h] += score[h];
                }
            }
        }
        ll ans_loc = numeric_limits<ll>::min();
        rep(h,0,3) {
            ans_loc = max(ans_loc, dp[Ts[k].size()-1][h]);
        }
        ans += ans_loc;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6516
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >>a>>b>>c;
    if (a==b && b!=c) {
        cout << "Yes" << endl;
    }
    else if (a==c && a!=b) {
        cout << "Yes" << endl;
    }
    else if (b==c && b!=a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,x[505],a[250005],cnt[505],q,j;

pl t;

set <pl> s;
queue <int> v;


int main() {
    cin >> n;
    cin >> x[1]; a[x[1]]=1;
    for(int i=2;i<=n;i++) cin >> x[i],s.insert({x[i]-i,i}),a[x[i]]=i;
    q=n*n; j=1;
    for(int i=1;i<=q;i++){
        if(a[i]){
            if(cnt[a[i]]!=a[i]-1){
                cout << "No";
                return 0;
            }
            if(a[i]!=n) v.push(a[i]);
            continue;
        }
        if(s.size()){
            t=*s.begin();
            s.erase(s.begin());
            a[i]=t.y;
            cnt[t.y]++;
            if(cnt[t.y]!=t.y-1){
                t.x++;
                s.insert(t);
            }
        }
        else if(v.size()){
            a[i]=v.front();
            cnt[v.front()]++;
            while(v.size() && cnt[v.front()]==n-1) v.pop();
        }
        else{
            cout << "No";
            return 0;
        }
        //cout << a[i] << ' ';
    }
    cout << "Yes\n";
    for(int i=1;i<=q;i++) cout << a[i] << ' ';
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  vector<ll> max(n, 0);
  max[0] = a[0];

  for (int i = 1; i < n; i++) {
    if (max[i - 1] <= a[i])
      max[i] = a[i];
    else
      max[i] = max[i - 1];
    // cout << max[i];
  }

  ll ans = 0;

  for (int i = 0; i < n; i++) {
    ans += max[i] - a[i] >= 0 ? max[i] - a[i] : 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6424
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n,a[111111],b[111111],c[111111],d[111111],ans=0;
signed main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	for(int i=0;i<n;i++)cin>>c[i];
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	for(int i=n-1;i>=0;i--)d[i]=d[i+1]+n-(upper_bound(c,c+n,b[i])-c);
	for(int i=0;i<n;i++)ans+=d[upper_bound(b,b+n,a[i])-b];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;

int main(){
    
    long long n,min=10000000000000,b=0;
        
    scanf("%lld",&n);
        
    for(int i=1;i<=sqrt(n);i++){
        b=n/i;
        if(i*b==n){
            if(min>i+b-2) min=i+b-2;
        }
    }
        
    printf("%lld\n",min);
        
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

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

        int n = in.nextInt();
        int q = in.nextInt();
        String str = in.nextLine();
        int[] pre = new int[n];
        pre[0] = 0;
        for (int i=1; i<n; i++) {
            if (str.charAt(i - 1) == 'A' && str.charAt(i) == 'C') {
                pre[i] = pre[i - 1] + 1;
            } else {
                pre[i] = pre[i - 1];
            }
        }
        while(q-- > 0) {
            int l = in.nextInt();
            int r = in.nextInt();
            out.println(pre[r - 1] - pre[l - 1]);
        }
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public double[] nextDoubleArray(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        public char[] nextCharArray(int n) {
            char[] arr = nextLine().trim().replaceAll("\\s", "").toCharArray();
            return arr;
        }

        public String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 46304
s = input()
t = 0
u = 0
if "N" in s and "S" in s and "E" not in s and "W" not in s:
    print("Yes")
elif "N" not in s and "S" not in s and "E" in s and "W" in s:
    print("Yes")
elif "N" in s and "S" in s and "E" in s and "W" in s:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9120
#include <stdio.h>
int main(int argc, const char * argv[]) {
	int a = 0;
	int b = 0;
	scanf("%d %d", &a, &b);
	
	if(a < b) {
		printf("a < b");
	}else if(a > b) {
		printf("a > b");
	}else if(a == b) {
		printf("a == b");
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 584
n,m=map(int,input().split())
ac=0
wa=0
boac=[0]*n
bowa=[0]*n
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)-1

    if s=="WA":
        bowa[p]+=1

    if s=="AC" and boac[p]==0:
        boac[p]=1
        ac+=1
        wa+=bowa[p]

print(ac,wa)

Measured memory_bytes: 4596
n = int(input())
a = [int(input()) for _ in range(n)]
t = 0
for x in a: t ^= x
s = set((x&-x).bit_length() for x in a)
cnt = 0
while t:
  if t.bit_length() in s:
    cnt += 1
    t ^= (1 << t.bit_length()) - 1
  else:
    print(-1)
    break
else: print(cnt)

Measured memory_bytes: 7072
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		int MOD = 1000000007;

		Scanner sc = new Scanner(System.in);
		Long first_N = sc.nextLong();
		Long first_M = sc.nextLong();

		Long first_limit;

		if(first_N == 1){
			System.out.println((first_M+1)%MOD);
		}else{

			if((first_M+1)%(first_N-1) == 0){
				first_limit = (first_M+1)/(first_N-1)-1;
			}else{
				first_limit = (first_M+1)/(first_N-1);
			}

			if(first_limit <= 0){
				System.out.println((first_M+1)%MOD);
			}else{

				BigInteger bigMOD = BigInteger.valueOf(MOD);

				BigInteger limit = BigInteger.valueOf(first_limit);

				BigInteger A = BigInteger.valueOf(first_M+1);

				BigInteger B = BigInteger.valueOf(2*(first_M+1)).multiply(limit);

				BigInteger C = BigInteger.valueOf(first_N-1).multiply(limit);
				C = C.multiply(BigInteger.valueOf(first_limit+1));

				System.out.println((A.add(B).subtract(C)).remainder(bigMOD));
			}
		}
	}
}

Measured memory_bytes: 26600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

bool isKaibun(string s) {
    int n = s.length();
    bool ok = true;
    for (int i = 0; i < n/2; i++) {
        if (s[i] != s[n-i-1]) ok = false;
    }
    return ok;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll ans = 0;
    string s; cin >> s;

    int n = s.length();

    string s1 = s.substr(0, (n-1)/2);
    string s2 = s.substr((n+1)/2, (n-1)/2);

    (isKaibun(s) && isKaibun(s1) && isKaibun(s2)) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

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

#define FOR(i,n) for(int i=0;i<n;i++)
#define PRINT(a) cout<<a<<"\n"
 
int main(){

	char a[10],s[100],b[10];

	cin>>a>>s>>b;

	cout<<"A"<<s[0]<<"C"<<endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

//そのまま行うとオーバーフローするし、倍精度不動小数点数で計算を行うと精度が足りない。、多倍長整数で最後まで計算するとTLEするので(pythonならOK)、10^18を超えないように

//乗算でなく、除算で求める。
//
int main(){
  ll n;
  cin>>n;

  ll a[n];
  ll ans=1;
  for(int i=0; i<n; i++){ 
    cin>>a[i];
    if(a[i]==0) ans=0;
  }

  for(int i=0; i<n; i++){
    if(ans==0){
      break;
    }else{
      if(a[i]<=1000000000000000000/ans){
        ans=ans*a[i];
      }else{
        ans=-1;
        break;
      }
    }
  }
  
  cout<<ans<<endl;

  
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  vector<ll> ub(3);
  cin >> ub[0] >> ub[1];
  ub[2] = ub[0] + ub[1];
  vector<ll> a(3);
  REP(i, 3) { cin >> a[i]; }
  vector<vector<ll>> p(3, vector<ll>(1e5 + 1));
  REP(i, 3) {
    REP(j, a[i]) { cin >> p[i][j]; }
  }
  REP(i, 3) {
    sort(ALL(p[i]));
    reverse(ALL(p[i]));
  }
  ll ans = 0;
  vector<ll> pos(3, 0);
  while (true) {
    ll m = -1, idx = -1;
    REP(i, 3) {
      if (pos[i] >= a[i]) {
        continue;
      }
      ll t = p[i][pos[i]];
      if (m < t && pos[i] < ub[i]) {
        m = t;
        idx = i;
      }
    }
    ans += m;
    pos[idx]++;
    if (pos[0] + pos[1] + pos[2] == ub[2]) {
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

typedef long long ll;
const int N = 400;

double dp[N][N][N];

double n;

double calc(int i, int j, int k) {
    if(!i && !j && !k) return 0;

    double &r = dp[i][j][k];
    if(r != -1) return r;

    double res = 1;
    if(i) res += i / n * calc(i - 1, j, k);
    if(j) res += j / n * calc(i + 1, j - 1, k);
    if(k) res += k / n * calc(i, j + 1, k - 1);
    res /= (i + j + k) / n;
    return r = res;
}

int main() {
    cin >> n;
    int one = 0, two = 0, three = 0;
    fore(i, 0, n) {
        int x; cin >> x;
        if(x == 1) one++;
        else if(x == 2) two++;
        else three++;
    }
    fore(i, 0, n + 1) fore(j, 0, n + 1) fore(k, 0, n + 1) dp[i][j][k] = -1;
    cout.precision(20);
    cout << calc(one, two, three) << endl;
    return 0;
}

Measured memory_bytes: 376832
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


a, b = MI()
P((a-1) * (b-1))


Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
void input()
{ 
  #ifndef ONLINE_JUDGE 
  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
  #endif
}
typedef long long int ll;
#define rep(i,a,b) for( ll i=a;i<b;i++)
#define rrep(i,a,b)for(ll i=a;i>=b;i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define f first
#define s second
#define mod 1000000007
bool compare(pair<int,int>a,pair<int,int>b)
{
  return a.f<b.f;
}
int main()
{
  //input();
  ios_base::sync_with_stdio(0);
    cin.tie(0);
 int n,m;
 string a,b,ans="";
 cin>>a>>b;
 n=a.length(),m=b.length();
int dp[n+1][m+1]={};
rep(i,1,n+1)
{
  rep(j,1,m+1)
  {
    //cout<<"hi";
    if(a[i-1]==b[j-1])
    {
      dp[i][j]=1+dp[i-1][j-1];
    }
    else
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    //cout<<dp[i][j]<<" ";
  }
  //cout<<endl;
}
int i=n,j=m;
while(i>=1&&j>=1)
{
  if(a[i-1]==b[j-1])
  {
    //cout<<a[i-1];
    ans+=a[i-1];
    j--,i--;
  }
  else
  {
    if(dp[i][j]==dp[i-1][j])i--;
    else j--;
  }
}
reverse(ans.begin(),ans.end());
cout<<ans;
//cout<<dp[n][m]<<endl;
}

///shubham gupta/


Measured memory_bytes: 35456
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main() {
	string s; cin >> s;
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'a')a++;
		else if (s[i] == 'b')b++;
		else c++;
	}
	cout << ((abs(a - b) <= 1 && abs(b - c) <= 1 && abs(c - a) <= 1) ? "YES\n" : "NO\n");
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n, a;
    cin >> n >> a;

    // 処理
    if (n % 500 <= a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    // 出力

    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[1 << 21], adj[21][21], N;

int solve(int bit) {
    int &val = dp[bit];
    if(val >= 0) return val;
    if(bit == 0) return val = 1;

    val = 0;
    int x = __builtin_popcount(bit) - 1;
    for(int y=0; y<N; y++) {
        if(!(bit >> y & 1)) continue;
        if(adj[x][y] == 0) continue;
        int nbit = bit ^ (1 << y);
        (val += solve(nbit)) %= MOD;
    }
    return val;
}

signed main() {
    cin >> N;
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            cin >> adj[i][j];
        }            
    }

    fill(dp, dp + (1<<N), -1);
    cout << solve((1<<N) - 1) << endl;
    return 0;
}


Measured memory_bytes: 16640
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        p: [usize; n]
    };

    let p: Vec<usize> = p;

    let mut p_clone = p.clone();
    p_clone.sort();

    let mut count = 0;

    for (i, j) in p.iter().zip(p_clone.iter()) {
        if i != j {
            count += 1;

            if count > 2 {
                break;
            }
        }
    }

    if count > 2 {
        println!("NO");
    } else {
        println!("YES");
    }
}


Measured memory_bytes: 2176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC_109_A solver = new ABC_109_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC_109_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            if (a * b % 2 != 0) {
                out.print("Yes");
            } else {
                out.print("No");
            }
        }

    }
}



Measured memory_bytes: 22996
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  string S; cin >> S;
  deque <char> deq;
  for (int i = 0; i < S.length(); i++){
    deq.push_back(S[i]);
  }

  int Reverse = 0;
  int Q; cin >> Q;
  for (int i = 0; i < Q; i++){
    int T; cin >> T;
    if (T == 1){
      Reverse = 1 - Reverse;
      continue;
    }

    int F; char C; cin >> F >> C;

    if (Reverse == 0){
      if (F == 1) deq.push_front(C);
      else deq.push_back(C);
    }else{
      if (F == 1) deq.push_back(C);
      else deq.push_front(C);
    }
  }
  
  if (Reverse == 0){
    while (!deq.empty()){
      char now = deq.front(); deq.pop_front();
      cout << now;
    }
  }else{
    while (!deq.empty()){
      char now = deq.back(); deq.pop_back();
      cout << now;
    }
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>

using int64 = long long;
int main(void) {
  int n;
  std::string a, b, c;
  while (std::cin >> n) {
    std::cin >> a >> b >> c;
    int cost = 0;
    for (int i = 0; i < n; i++) {
      bool x = a[i] == b[i];
      bool y = b[i] == c[i];
      bool z = a[i] == c[i];

      if (x && y) {
      } else if (x || y || z) {
        cost += 1;
      } else {
        cost += 2;
      }
    }
    std::cout << cost << std::endl;
  }
}


Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

s,w = gets.split.map(&:to_i)

puts s <= w ? "unsafe" : "safe" 

Measured memory_bytes: 14328
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;



const int N = 2e5+33, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11 , T = 2000;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;        // #include <ext/pb_ds/assoc_container.hpp>
typedef pair <ll, ll> pll;         // #include <ext/pb_ds/tree_policy.hpp>
typedef vector <int> vi;          // #include <ext/rope>
                // #include <ext/rope>
                                 // #include <ext/rope>
bool prime(int n) {             // template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

void solve() {
    ll x;
    cin >> x;
    for(ll i = -1000; i <= 1000; i ++) {
        for(ll j = -1000; j <= 1000; j ++) {
            if(pow(i , 5) - pow(j , 5) == x) {
                cout << i << ' ' << j;
                return;
            }
        }
    }
}
/*

*/

main() {
    ios;
    int tt = 1;
//    cin >> tt;
    while(tt --) {
        solve();
//        brute();
    }
    return 0;
}
/*

*/


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

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>>C(10, vector<int>(10)), A(H, vector<int>(W));
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			cin >> C.at(i).at(j);
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A.at(i).at(j);
		}
	}
	for (int k = 0; k <= 9; k++){
		for (int i = 0; i <= 9; i++) {
			for (int j = 0; j <= 9; j++) {
				if (C.at(i).at(j) > C.at(i).at(k) + C.at(k).at(j)) C.at(i).at(j) = C.at(i).at(k) + C.at(k).at(j);
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A.at(i).at(j) >= 0) {
				ans += C.at(A.at(i).at(j)).at(1);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
# AGC 025: A – Digits Sum
N = int(input())
n = N // 2 if N % 2 == 0 else N // 2 + 1
min_sum = 9999

for i in range(1, n + 1):
    sum_digits = 0
    A = i
    B = N - i

    while A != 0:
        sum_digits += A % 10
        A //= 10
    
    while B != 0:
        sum_digits += B % 10
        B //= 10
        
    min_sum = min(min_sum, sum_digits)

print(min_sum)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,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;}

ll DP[3002][3002][4],L[3002][3002];

int main(){
  ll R,C,K;
  cin>>R>>C>>K;
  
  for(int i=0; i<=3001; ++i){
    for(int j=0; j<=3001; ++j){
      L[i][j]=-1;
      for(int k=0; k<4; ++k){
        DP[i][j][k]=0;
      }
    }
  }
  
  ll RR[K],CC[K],VV[K];
  REP(i,K){
    cin>>RR[i]>>CC[i]>>VV[i];
    L[RR[i]][CC[i]]=VV[i];
  }
  
  
  for(int i=1; i<=3001; ++i){
    for(int j=1; j<=3001; ++j){
      for(int k=0; k<4; ++k){
        if(L[i][j]!=-1){
          if(k<3) chmax(DP[i][j][k+1],DP[i][j-1][k]+L[i][j]);
          chmax(DP[i][j][1],DP[i-1][j][k]+L[i][j]);
        }
        chmax(DP[i][j][k],DP[i][j-1][k]);
        chmax(DP[i][j][0],DP[i-1][j][k]);
      }
    }
  }
  
  cout<<DP[3001][3001][0]<<endl;
  return 0;
}

Measured memory_bytes: 360280
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  
  double sum = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int x = v[i].first-v[j].first, y = v[i].second-v[j].second;
      double d = sqrt(x*x + y*y);
      sum += d;
    }
  }
  
  cout << fixed << setprecision(7);
  cout << 2*sum/(1.0*n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

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

void rec(ll v, const vvll& G, vector<bool>& seen, vll& order) {
  seen[v] = true;
  for (auto next : G[v]) {
    if (seen[next]) continue;
    rec(next, G, seen, order);
  }
  order.push_back(v);
}

signed main() {
  init();
  ll N, M;
  cin >> N >> M;

  vvll G(N);
  vvll G2(N);
  rep(i, N + M - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].pb(b);
    G2[b].pb(a);
  }

  vector<bool> seen(N, 0);
  vll order;
  rep(i, N) {
    if (seen[i]) continue;
    rec(i, G, seen, order);
  }
  REVERSE(order);

  vll order2(N);
  rep(i, N) order2[order[i]] = i;

  rep(i, N) {
    ll max_index = -1;
    ll ma = -1;
    for (auto gg : G2[i])
      if (ma < order2[gg]) {
        max_index = gg;
        ma = order2[gg];
      }

    COUT(max_index + 1);
  }

  return 0;
}

Measured memory_bytes: 21192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(),b=s.nextInt();
        if(a<b) System.out.println(0);
        else System.out.println(10);
    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25352
while line = gets
    h, w = line.chomp.split.map(&:to_i)
    #puts "#{h} #{w}"
    break if h == 0 && w == 0
    
    h.times do |i|
        w.times do |j|
            if (i == 0 && j == 0) || (i + j) % 2 == 0
                print "#"
            else
                print "."
            end
        end
        puts ""
    end
    puts ""
end

Measured memory_bytes: 8880