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

#define rep(i, N) for(int (i) = 0; (i) < (N); i++)
#define all(v) v.begin(), v.end()
using i64 = int_fast64_t;

int main(){
    string S;
    cin >> S;
    int ans = 7;
    if(S == "MON") ans = 6;
    if(S == "TUE") ans = 5;
    if(S == "WED") ans = 4;
    if(S == "THU") ans = 3;
    if(S == "FRI") ans = 2;
    if(S == "SAT") ans = 1;

    cout << ans << endl;
}

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


int score(int table[][4], int* a, int q) {
  int ans = 0;
  for(int i=0; i<q; i++) {
    if(a[table[i][1]] - a[table[i][0]] == table[i][2]) ans += table[i][3];
  }

  return ans;
}

int main() {
  int n,m,q;
  cin>>n>>m>>q;
  int table[q][4];
  for(int i=0; i<q; i++) {
    cin>>table[i][0]>>table[i][1]>>table[i][2]>>table[i][3];
  }

  int a[n+1];
  for(int i=0; i<=n; i++) a[i]=1;
  int ans = score(table, a, q);
  while(1) {
    a[n]++;
    if(a[n]>m) {
      int check = n-1;
      while(a[check]==m) check--;
      a[check]++;
      for(int i=check+1; i<=n; i++) a[i]=a[check];
    }
    if(a[0]>1) break;

    ans = max(ans, score(table, a, q));
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	var ret float64
	for n := 1; n <= N; n++ {
		ret += math.Pow(float64(0.5), float64(a(n, K)))
	}
	fmt.Println(ret / float64(N))
}

func a(n, K int) int {
	if K <= n {
		return 0
	}
	l := math.Log2(float64(K) / float64(n))
	return int(math.Ceil(l))
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N,K;
    cin >> N >> K;
    ll h[N];
    rep(i,N) cin >> h[i];
    sort(h,h+N);
    ll out = 1000000000;
    rep(i,N-K+1){
        if(h[i+K-1]-h[i]<out) out = h[i+K-1]-h[i];
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>

using namespace std;

int main() {
	string s;
	cin >> s;
	bool tf = true;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < s.size(); j++) {
			if (i == j) {
				continue;
			}
			else {
				if (s[i] == s[j]) {
					tf = false;
					break;
				}
			}
		}
	}
	cout << (tf ? "yes" : "no") << endl;
}


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

int main(void) {
    int n;
    cin >> n;
    double ans = 0;
    for (int i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        } else {
            ans += x * 380000;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,x=gets.split.map &:to_i
a=gets.split.map(&:to_i).sort
i,ans=0,0
while i<n-1&&a[i]<=x
  ans+=1
  x-=a[i]
  i+=1
end
if i==n-1&&a[i]==x then ans+=1 end
p ans


Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
	int a,b,c,d=0;
	while(1){
	
		c=1;
		scanf("%d%d",&a,&b);
		if(a==0&&b==0){
			break;
		}
		if(d){
				printf("\n");
		}
		for(int i=a;i<=b;i++){
			if(i%4==0&&(i%100!=0||i%400==0)){
				printf("%d\n",i);
				c=0;
			}
		}
		if(c){
			printf("NA\n");
		}
		d=1;
	}
	return 0;
}

Measured memory_bytes: 2680
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;


int main(){
  int h, w;
  cin >> h >> w;
  string s[h];
  rep(i,h) cin >> s[i];

  int dp[h+2][w+2][4];
  rep(i,h+2){
    rep(j,4){
      dp[i][0][j] = 0;
      dp[i][w+1][j] = 0;
    }
  }
  rep(i,w+2){
    rep(j,4){
      dp[0][i][j] = 0;
      dp[h+1][i][j] = 0;
    }
  }

  rep(i,h){
    rep(j,w){
      char c = s[i][j];
      if (c == '#'){
        dp[i+1][j+1][0] = 0;
      }
      else{
        dp[i+1][j+1][0] = dp[i+1][j][0]+1;
      }
      c = s[h-i-1][w-j-1];
      if (c == '#'){
        dp[h-i][w-j][1] = 0;
      }
      else{
        dp[h-i][w-j][1] = dp[h-i][w-j+1][1]+1;
      }
    }
  }

  rep(i,w){
    rep(j,h){
      char c = s[j][i];
      if (c == '#'){
        dp[j+1][i+1][2] = 0;
      }
      else{
        dp[j+1][i+1][2] = dp[j][i+1][2]+1;
      }
      c = s[h-j-1][w-i-1];
      if (c == '#'){
        dp[h-j][w-i][3] = 0;
      }
      else{
        dp[h-j][w-i][3] = dp[h-j+1][w-i][3]+1;
      }
    }
  }

  int res[h][w];
  int ans = 0;
  rep(i,h){
    rep(j,w){
      res[i][j] = 0;
      bool flag = false;
      rep(k,4){
        if (dp[i+1][j+1][k] > 0){
          res[i][j] += dp[i+1][j+1][k]-1;
          flag = true;
        }
      }
      if (flag) ++res[i][j];
      if (res[i][j] > ans) ans = res[i][j];
    }
  }


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 82560
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
const int N=3e5+5;
using namespace std;
typedef long long ll;
typedef map<ll,ll>::iterator mit;
int n,q;
ll p[N];
map<ll,ll> mp;
ll cnt[N];
int main()
{
    scanf("%d%d",&n,&q);
    if(q==0){
        for(int i=1;i<=n;i++)
            puts("1");
        return 0;
    }
    for(int i=1;i<=q;i++)
        scanf("%lld",&p[i]);
    mp[p[q]]++;
    p[0]=n;
    for(int i=q-1;i>=0;i--){
        while(mp.rbegin()->first>p[i]){
            mit it=mp.end();
            it--;
            mp[it->first%p[i]]+=it->second;
            mp[p[i]]+=it->second*(it->first/p[i]);
            mp.erase(it);
        }
    }
    for(mit it=mp.begin();it!=mp.end();it++)
        cnt[it->first]+=it->second;
    for(int i=n;i>=1;i--)
        cnt[i]=cnt[i]+cnt[i+1];
    for(int i=1;i<=n;i++)
        printf("%lld\n",cnt[i]);
}


Measured memory_bytes: 10624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) (v).begin(),(v).end()
const ll MOD = 1e9 + 7;

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	A--; B--; C--; D--;
	string S;
	cin >> S;
	bool ok = 1;
	for (int i = A; i < C; i++) {
		if (S[i] == '#' && S[i + 1] == '#') {
			ok = 0;
			break;
		}
	}
	for (int i = B; i < D; i++) {
		if (S[i] == '#' && S[i + 1] == '#') {
			ok = 0;
			break;
		}
	}
	if (C > D) {
		bool ok2 = 0;
		for (int i = B; i <= D; i++) {
			if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
				ok2 = 1;
				break;
			}
		}
		ok &= ok2;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 640
fun main(args:Array<String>){
    val a=readLine()!!.split( " ")
    val b=readLine()!!.split( " ").map{it.toInt()}
    val c=readLine()!!
   if (a[0]==c){
        when {
            b[0]-1>=1 && b[1]>=1 ->{ println("${b[0]-1} ${b[1]}")}
            b[0]-1==0 && b[1]>=1 ->{ println("0 ${b[1]}")}
        }
    }else if (a[1]==c){
        when {
            b[0] >= 1 && b[1] - 1 >= 1 -> { println("${b[0]} ${b[1]-1}") }
            b[0] >= 1 && b[1] - 1 == 0 -> { println("0 ${b[0]}") }
        }
   }
}




Measured memory_bytes: 37876
import sys
input = lambda : sys.stdin.readline().rstrip()

# 小さすぎても怒られるので
from collections import defaultdict
n = int(input())
sys.setrecursionlimit(max(1000, 2*n))

cs = [0] + [int(c) for c in input().split()]
ns = defaultdict(set)
for _ in range(n-1):
    a,b = [int(c) for c in input().split()]
    ns[a].add(b)
    ns[b].add(a)

ans = [0] * (n+1) # kを通らないパスの総数
minus = [0] * (n+1) # uの部分木のうち
minus0 = defaultdict(int)
st = {k: [] for k in range(1, n+1)}
nextu = {}
def dfs(u, prev, ans):
    global minus, st, minus0
    k = cs[u]
    st[k].append(u)
    ss = 1
    for v in ns[u]:
        if v==prev:
            continue
        nextu[u] = v
        s = dfs(v, u, ans)
        ss += s
        tmp = s - minus[v]
        ans[k] += (int(tmp * (tmp - 1) / 2) + tmp)
    st[k].pop()
    if st[k]:
        minus[nextu[st[k][-1]]] += ss
    else:
        minus0[k] += ss
#     print(ss)
    return ss

dfs(1, -1, ans)
for k in range(1, n+1):
    tmp = n - minus0[k]
    ans[k] += (int(tmp * (tmp - 1) / 2) + tmp)
    
total = int(n * (n+1) / 2)
for i in range(1, n+1):
    print(total - ans[i])

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

int main() {
  int N,i,j;
  cin >> N;
  for(i=0; i<30; i++){
    for(j=0;j<30;j++){
      if(4*i+7*j==N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 3636
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s;
cin >> s;
for(ll i = 0; i < s.size(); i++){
    if(s[i] == '?')
        cout << 'D';
    else
        cout << s[i];
}
cout << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <stdio.h>
#include <string.h>
using namespace std;
 
int main(void){
 
  int N;
 
  // char str[1000];
  string str;
 
  cin >> N >> str;

  for(int i=0; i<=str.size(); i++){
    if(str[i]>=65 && str[i]<=90)
      str[i] = str[i] + N;
      if (str[i] >= 91) {
        str[i] -= 26;
      }
  }


  // printf("%s\n", str);
  cout << str << endl;
 
  return 0;
}

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

using namespace std;

const long long MOD = 1e9 + 7;

int main(){
 int H,W,K; cin >> H >> W >> K; K--;
  vector<vector<long long >> dp( H + 1, vector<long long>(W,0));
  
  dp[0][0] = 1;
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      for(int bit = 0; bit < ( 1 << ( W - 1)); bit++){
        bool flag = true;
        for(int k = 0; k < W - 2; k++){
          if( ( bit & (1 << k) ) && (bit & (1 << ( k + 1))) ){
            flag = false;}}
         if( !flag){ continue;}
             
             int nj = j;
             if( bit & 1 << j){ nj++;}
             else if( j > 0 && bit & 1 << ( j-1 )){ nj--;}
             
             dp[i+1][nj] += dp[i][j]; dp[i+1][nj] %= MOD;}}}
             
    cout << dp[H][K] << endl; return 0;}

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

typedef long long ll;

ll W, H, X, Y;

int main() {
  cin >> W >> H >> X >> Y;
  cout << W * H / 2. << " " << (2 * X == W && 2 * Y == H ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy

inp=input().split(" ")
n=int(inp[0])
m=int(inp[1])
inh=input().split(" ")
for i in range(len(inh)):
  inh[i]=int(inh[i])
pairs=numpy.zeros(2*m,dtype=">i4").reshape(-1,2)
for i in range(m):
  a=input().split(" ")
  pairs[i][0]=int(a[0])
  pairs[i][1]=int(a[1])
lists=[[] for i in range(n)]
for i in range(len(pairs)):
  lists[pairs[i][0]-1].append(pairs[i][1]-1)
  lists[pairs[i][1]-1].append(pairs[i][0]-1)
for i in range(len(lists)):
  lists[i]=list(set(lists[i]))
count=0
for i in range(len(lists)):
  if len(lists[i])==0:
    count+=1
    continue
  for j in range(len(lists[i])):
    if inh[i] <= inh[lists[i][j]]:
      break
    if j == len(lists[i])-1:
      count+=1
print(count)

Measured memory_bytes: 50744
from sys import stdin
import math
import itertools

n,d = [int(x) for x in stdin.readline().rstrip().split()]
li = [tuple(map(int,stdin.readline().rstrip().split())) for _ in range(n)]

li2 = list(itertools.combinations(li, 2))

point  = 0

for i in range(len(li2)):
    score = 0
    for j in range(d):
        score += int(li2[i][1][j] - li2[i][0][j])**2
    if round(math.sqrt(score)) - math.sqrt(score) == 0.0:
        point += 1
print(point)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string ans;
  
  // ここにプログラムを追記
  for(int i = 0; i < N; i++){
    string hina;
    cin >> hina;
    
    if (hina == "Y"){
      cout << "Four" << endl;
      exit(0);
    }
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
    int N, K;
    std::cin >> N >> K;
    std::vector<int> xn;
    for (int i = 0; i < N; ++i) {
        int x;
        std::cin >> x;
        xn.push_back(x);
    }

    int result = 0;
    for (int i = 0; i < N; ++i) {
        result += std::min(xn[i], std::abs(xn[i] - K)) * 2;
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl

bool sosuu(const int x)
{
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}
int gcd(int a, int b)
{
	if (a % b == 0) { return b; }
	else { return gcd(b, a % b); }
}
int ketawa(int a)
{
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0,ans=0;
string s, t;


int main()
{

	cin >> s;
	map<char, int> ans;
	rep(i, sz(s))
	{
		ans[s[i]]++;
	}
	for (auto iter=ans.begin();iter!=ans.end();iter++)
	{
		if (iter->second% 2==1)
		{
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();

    stdin
        .read_line(&mut buf)
        .unwrap();

    let ab: Vec<usize> = buf.split_whitespace().map(|n| n.parse().unwrap()).collect();

    buf = String::new();

    stdin
        .read_line(&mut buf)
        .unwrap();

    let splited: Vec<&str> = buf.trim().split("-").collect();
    let mut flag = true;

    if splited.len() == 2 {
        for ch in splited[0].chars().chain(splited[1].chars()) {
            flag = ch.is_digit(10);
        }
        flag = (splited[0].len() == ab[0]) && (splited[1].len() == ab[1]);
    } else {
        flag = false;
    }

    println!("{}", if flag { "Yes" } else { "No"} );
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] p = new int[n];
		int[] x = new int[m];
		int[] y = new int[m];
		for(int i = 0 ; i < n ; i++) p[i] = sc.nextInt() - 1;
		for(int i = 0 ; i < m ; i++) {
			x[i] = sc.nextInt() - 1;
			y[i] = sc.nextInt() - 1;
		}
		UnionFind uf = new UnionFind(n);
		for(int i = 0 ; i < m ; i++) uf.unite(x[i], y[i]);
//		System.out.println(Arrays.toString(uf.par));
//		System.out.println(Arrays.toString(uf.rank));
		int ans = 0;
		for(int i = 0 ; i < n ; i++) {
			if(i == p[i] || uf.root(i) == uf.root(p[i])) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

class UnionFind {
	int[] par, rank;
	UnionFind(int n) {
		par = new int[n];
		rank = new int[n];
		for(int i = 0 ; i < n ; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int root(int x) {
		if(par[x] == x) return x;
		else return par[x] = root(par[x]);
	}
	boolean same(int x, int y) {
		if(root(x) == root(y)) return true;
		else return false;
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if(x == y) return;
		if(rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const ll inf = 1e9;

vector<int> divisor(int n)
{
  vector<int> res;
  for (int i=1; i*i<=n; i++) {
    if (n%i == 0) {
      res.push_back(i);
      if (i != n/i) res.push_back(n/i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

void solve()
{
  ll N;
  scanf("%lld",&N);
  ll ans=0;
  for (int i=1; i<=N; i+=2) {
    vector<int> a = divisor(i);
    if ((int)(a.size())==8) ans++;
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll a, b, x;
    cin >> a >> b >> x;
    if (a == 0) cout << b / x + 1 << endl;
    else cout << b / x - (a - 1) / x << endl;
}


Measured memory_bytes: 3636
stones = int(input())
stone_heights = [int(x) for x in input().split()]

dp = [-1] * stones

dp[0] = 0
dp[1] = abs(stone_heights[1] - stone_heights[0])

for i in range(2, stones):
	dp[i] = min(
		abs(stone_heights[i - 1] - stone_heights[i]) + dp[i - 1],
		abs(stone_heights[i - 2] - stone_heights[i]) + dp[i - 2]
	)
print(dp[-1])

Measured memory_bytes: 13780
/**
* Think twice, code once.
* 1.integer overflow(maybe even long long overflow : (a+b >= c) -> (a >= c-b)
* 2.runtime error
* 3.boundary condition
* ---------------------------------------------------------------------------------------
* Author : zzy
* Date : 2020-03-19-18.25.37 Thursday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 maxn = (i64)1e5+1000;
i64 N, W, w[maxn], v[maxn], dp[110][maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> N >> W;
    for1(i, N) cin >> w[i] >> v[i];
    ms(dp, 0);
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= W; ++j) {
            dp[i][j] = dp[i-1][j];
            if (j >= w[i]) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 88320
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    ll a, x[n], sum, ans = INFTY;
    rep(i, n){
        cin >> a;
        if(i){
            x[i] = x[i - 1] + a;
        }else{
            x[i] = a;
        }
    }
    sum = x[n - 1];
    
    ll y, tmp;
    FOR(i, 0, n - 1){
        y = sum - x[i];
        tmp = abs(x[i] - y);
        if(tmp < ans || i == 0){
            ans = tmp;
        }
        //cout << tmp << " " << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



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

   if((a==b && a != c) or (b==c and b != a) or (a == c and a != b)){
       cout<<"Yes\n";
   }else cout<<"No\n";



   








}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

using namespace std;

int main()
{
    int n, m, d;
    int s;
    int M;
    string str;
    map<string, int> names;
    vector<int> v[30];
    int a[20];
    while(cin >> n && n)
    {
        names.clear();
        for(int i=0;i<n;++i) a[i] = 0;
        for(int i=0;i<30;++i) v[i].clear();
        for(int i=0;i<n;++i)
        {
            cin >> str;
            names[str] = i;
            cin >> m;
            for(int j=0;j<m;++j)
            {
                cin >> d;
                v[d].push_back(i);
            }
        }
        for(int i=0;i<30;++i)
        {
            s = v[i].size();
            for(int j=0;j<s;++j) a[v[i][j]] += n-s+1; 
        }
        map<string, int>::iterator it=names.begin();
        M = 100000;
        for(;it!=names.end();++it)
        {
            if(M > a[(*it).second])
            {
                str = (*it).first;
                M = a[(*it).second];
            }
        }
        cout << a[names[str]] << ' ' << str << endl;
    }
}

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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}
string alpha = "abcdefghijklmnopqrstuvwxyz" ;

 
/*CODE START HERE*/
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  forn(i,n){
    cin >> a.at(i) ;
  }
  int count = 0;
  int ans = 0;
  forn(i,n-1){
    if ( a.at(i+1) <= a.at(i)){
      count ++ ;
      ans = max ( count , ans ) ;
    }else if (a.at(i+1) > a.at(i)){
      count = 0 ;
    }
  }
  cout << ans << endl;
}

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

int main(){
    string S;
    cin >> S;
    int cnt = 0, n = 0;
    if(S[0] == 'R'){
        cnt++;
        n++;
        if(S[1] == 'R'){
            cnt++;
            if(S[2] == 'R'){
                cnt++;
                cout << cnt << endl;
                return 0;
            }
            if(S[2] == 'S'){
                cout << cnt << endl;
                return 0;
            }  
        }
         if(S[1] == 'S'){
            cout << cnt << endl;
            return 0;
        }
    }
    if(S[0] == 'S'){
        if(S[1] == 'R'){
            cnt++;
            if(S[2] == 'R'){
                cnt++;
                cout << cnt << endl;
                return 0;
            }
            if(S[2] == 'S'){
                cout << cnt << endl;
                return 0;
            }  
        }
        if(S[1] == 'S'){
            if(S[2] == 'R'){
                cnt++;
                cout << cnt << endl;
                return 0;
            }
            cout << cnt << endl;
            return 0;
        }
    }
}    

Measured memory_bytes: 3624
# https://atcoder.jp/contests/abc066/tasks/abc066_b
import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    s = input()
    for i in range(1, len(s) - 1):
        new_s = s[:len(s) - i]
        if len(new_s) % 2 != 0:
            continue
        front = new_s[:len(new_s) // 2]
        back = new_s[len(new_s) // 2:]
        if front == back:
            print(len(new_s))
            exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{   
    int N;
    cin >> N;
    vector<int> X,Y;
    for(int i=0; i<N; i++)
    {
    	int x;
    	cin >> x;
    	X.push_back(x);
    }
    Y = X;
    sort(Y.begin(), Y.end());

    for(int i=0; i<N; i++)
    {
       if (X[i]<=Y[N/2-1]) cout << Y[N/2] << endl;
       else cout << Y[N/2-1] << endl;	
    }

	return 0;
}

Measured memory_bytes: 3828
D,G=map(int,input().split())

pc=[list(map(int,input().split())) for i in range(D)]

ans=float('inf')

for i in range(1<<D):
    s=0
    c=0
    for k in range(D):
        if 1&i>>k:
            s+=(k+1)*100*pc[k][0]+pc[k][1]
            c+=pc[k][0]

    if s>=G:
        ans=min(ans,c)

    if s<G:
        for k in reversed(range(D)):
            if not(1&i>>k):
                ac=-(-(G-s)//((k+1)*100))
                if  pc[k][0]>ac:
                    ans=min(ans,c+ac)
                    break
print(ans)


Measured memory_bytes: 3064
using System;
using System.Text;

class Program
{
    static void Main(string[] args) {
        String ret;
        ret = process(new System.IO.StreamReader(Console.OpenStandardInput()));

        Console.WriteLine(ret);
        Console.ReadLine();
    }

    static string process(System.IO.TextReader input) {
        int n   = int.Parse(input.ReadLine());
        int[] a = new int[n];

        StringBuilder ret = new StringBuilder();

        int max = 0;
        int second = 0;

        for(int i=0; i<n; i++) {
            a[i] = int.Parse(input.ReadLine());
            if(max < a[i]) {
                second = max;
                max = a[i];
            }else if(second < a[i]) {
                second = a[i];
            }
        }
        
        for(int i=0; i<n; i++) {
            if(a[i] == max) {
                ret.AppendLine(second.ToString());
            } else {
                ret.AppendLine(max.ToString());
            }
        }
        return ret.ToString();
    }

    static string process(string input) {
        return process(new System.IO.StringReader(input));
    }
}

Measured memory_bytes: 25428
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
using mint=modint998244353;
struct S{mint value,p;};
S op(S a,S b){return S{a.value+b.value,a.p+b.p};}
S e(){return S{0,0};}
using F=int;
S mapping(F f,S x){
    if(f==0) return x;
    return S{x.p*f,x.p};
}
F composition(F f,F g){
    if(f==0) return g;
    return f;
}
F id(){return 0;};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q;
    cin>>n>>q;
    lazy_segtree<S,op,e,F,mapping,composition,id> G(n);
    mint a=1;
    rep(i,n) G.set(n-1-i,S{a,a}),a*=10;
    rep(i,q){
        int l,r,d;
        cin>>l>>r>>d;
        G.apply(l-1,r,d);
        cout<<G.all_prod().value.val()<<"\n";
    }
}

Measured memory_bytes: 9836
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

//macro
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,a,b) for(int i=(int)(b) - 1;i>=(int)(a);i--)
#define rrep(i,n) RREP(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define INF 114514810
#define INFL 1145148100000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define equals(a,b)(fabs((a)-(b))<EPS)

//alias
using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<ll, ll>;
template<class T> using heap = priority_queue<T>;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;

//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H);	rep(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n)os << v[i] << (i == n - 1 ? "\n" : " "); return os; }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template<class T> inline void print(const T &x) { cout << x << '\n'; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;



int main() {
	string X, Y;
	cin >> X >> Y;
	if (X < Y) {
		print("<");
	}
	else if (X > Y) {
		print(">");
	}
	else {
		print("=");
	}
	return 0;
}

Measured memory_bytes: 768
from bisect import bisect_left

def main():
    N = int(input())
    S = tuple(map(int, tuple(input())))
    place = [[] for _ in range(10)]
    for i, c in enumerate(S):
        place[c].append(i)
    ans = 0
    for i in range(10):
        temp = bisect_left(place[i], 0)
        if temp == len(place[i]):
            continue
        idx_1 = place[i][temp]

        for j in range(10):
            temp = bisect_left(place[j], idx_1+1)
            if temp == len(place[j]):
                continue
            idx_2 = place[j][temp]
            
            for k in range(10):
                temp = bisect_left(place[k], idx_2+1)
                if temp == len(place[k]):
                    continue
                ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 4612
N = int(input())

A = map(int, input().split())
B = map(int, input().split())
A = list(A)
B = list(B)

sum_r = 0
pre_h_beat = 0
for i, b in enumerate(B):
    if i == 0:
        left_beat = min(b, A[i])
    else:
        left_beat = min(remain_mon, b)

    sum_r += left_beat

    cap_remain_beat = b - left_beat

    right_beat = min(cap_remain_beat, A[i + 1])

    sum_r += right_beat

    remain_mon = A[i + 1] - right_beat

print(sum_r)


Measured memory_bytes: 21824
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;

///---program start---///

int a[arr];

main()
{
    #ifdef Barik
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    int n;
    cin>>n;
    n*=2;
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int res=0;
    for (int i=0;i<n;i+=2){
        res+=a[i];
    }
    cout<<res<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)

#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//grobal var
//------------------------------------------
const int MAX = 2*10e5+2;


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  str S;
  while(cin >> S){
    str ans="NO";
    int cnt=0;
    EACH(i,S){
      if(*i=='x') cnt++;
    }
    if(cnt<8) ans = "YES";

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split(' ')))
H = [0] + H + [10**10]

ans = 'Yes'
for _i in range(N):
    i = _i + 1

    if H[i-1] <= H[i]-1 and H[i]-1 <= H[i+1]:
        H[i] -= 1

    if H[i-1] <= H[i] and H[i] <= H[i+1]:
        continue
    else:
        ans = 'No'

print(ans)

Measured memory_bytes: 64732
#include <cstdio>
#include<math.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
ll a, b;
int G(int n) 
{
	for (int i = 1; i <= 9; i++) 
    {
		if (n % i == 0)
        {
			if (n / i <= 9)return 1;
		}
	}
	return 0;

}
int main() 
{
	int X ;
	cin>>X;
	if (G(X))
      cout << "Yes";
	else 
      cout << "No";

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = 0, cnt = 0;
    for (ll i = 0; i < n;i++){
        if(s[i]=='B'&&i!=n-1){
            cnt++;
        }
        if(s[i]=='W'){
            ans += cnt;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 2048;

int ans[N];

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n, x, y;
    cin >> n >> x >> y;

    for (int i = 1; i <= n; i++) {
        for (int j = i+1; j <= n; j++) {
            int dist = min({
                j - i,
                abs(j - x) + 1 + abs(y - i),
                abs(j - y) + 1 + abs(x - i)
            });
            ans[dist]++;
        }
    }

    for (int i = 1; i < n; i++)
        cout << ans[i] << endl;



    return 0;
%>

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S;
    cin >> S;
    sort(ALL(S));
    UNIQUE(S);
    if(S.size() == 1 || S.size() == 3){
        cout << "No" << "\n";
    }else if(S.size() == 4){
        cout << "Yes" << "\n";
    }else{
        if(S[0] == 'N' && S[1] == 'S'){
            cout << "Yes" << "\n";
        }else if(S[0] == 'E' && S[1] == 'W'){
            cout << "Yes" << "\n";
        }else{
            cout << "No" << "\n";
        }
    }
}

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

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

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

#define _LIBCPP_DEBUG 0
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s="";
  cin >> s;
  
  string sc = s;
  reverse(sc.begin(), sc.end());

  if (sc.at(0) == 's') cout << s << "es" << endl;
  else cout << s << "s" << endl;
  return 0;
}


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

int main()
{
    ll n;
    ll x;
    ll y;
    cin >> n >> x >> y;

    auto res = map<tuple<ll, ll>, int>{};
    auto cost_map = map<int, int>{};

    auto k = 1;
    for (auto i = 1; i < n; i++)
    {
        for (auto j = i + 1; j <= n; j++)
        {
            auto min_route = j - i;
            int cost = abs(x - i) + 1 + abs(j - y);
            min_route = min(min_route, cost);
            auto t = make_tuple(i, j);

            res[t] = min_route;
            if (cost_map.count(min_route))
            {
                cost_map[min_route] = cost_map[min_route] + 1;
            }
            else
            {
                cost_map[min_route] = 1;
            }
        }
    }

    for (auto k = 1; k < n; k++)
    {
        if (cost_map.count(k))
        {
            cout << cost_map[k] << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 125312
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] luca = new long[n+1];
        luca[0] = 2;
        luca[1] = 1;
        for (int i = 2 ; i <= n ; i++) {
            luca[i] = luca[i-1] + luca[i-2];
        }
        System.out.println(luca[n]);
    }
}

Measured memory_bytes: 21844
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{s:chars};

    for i in 0..1 << s.len()-1 {
        //debug!(i);
        let mut t = s[0].to_string();
        let mut sum:i32 = (s[0] as u8 - b'0') as i32;
        for j in 0..s.len()-1 {
            if (1 << j) & i != 0 {
                sum += (s[j+1] as u8 - b'0') as i32;
                t.push('+');
            } else {
                sum -= (s[j+1] as u8 - b'0') as i32;
                t.push('-');
            }
            t.push(s[j+1]);
        }
        //debug!(t,sum);
        if sum == 7 {
            println!("{}=7", t);
            return ();
        }
    }

}

Measured memory_bytes: 4352