akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    int b = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i * m + j * n - i * j * 2 == k) b = 1;
        }
    }

    cout << (b ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}


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

    int cnt = 0;

    while (a > 0){
        cnt ++;
        a = a -b;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
mod = 1000000007
dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(0, len(s) + 1):
    for j in range(0, len(t) + 1):
        ret = 0
        if i == 0:
            ret = 1
        elif j == 0:
            ret = 1
        else:
            ret = (dp[i][j - 1] + dp[i - 1][j]) % mod
            if s[i - 1] != t[j - 1]:
                ret = (ret + mod - dp[i - 1][j - 1]) % mod
        dp[i][j] = ret
print(dp[len(s)][len(t)])


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

int main(){
    string s;
    cin >> s;
    
    int mindif = 999;
    for (int i = 0; i < s.size() - 2; i++) {
        string buf = s.substr(i,3);
        int bufnum = stoi(buf);
        int bufdif = abs(753 - bufnum);
        mindif = min(mindif,bufdif);
    }
    
    cout << mindif << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	Boolean[][] answers;
	int result = 0;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		this.N = Integer.parseInt(in.readLine());
		this.answers = new Boolean[N][N];
		for (int i = 0; i < N; ++i) {
			Arrays.fill(answers[i], null);
		}
		for (int i = 0; i < N; ++i) {
			int A = Integer.parseInt(in.readLine());
			for (int j = 0; j < A; ++j) {
				String[] tokens = in.readLine().split(" ");
				int x = Integer.parseInt(tokens[0]) - 1;
				int y = Integer.parseInt(tokens[1]);
				if (y == 1) {
					answers[i][x] = true;
				} else {
					answers[i][x] = false;
				}
			}
		}
	}

	void calc() {
		int max = (int) Math.pow(2, N);
		for (int i = 0; i < max; ++i) {
			int sub = sub(i);
			result = Math.max(result, sub);
		}
	}

	int sub(int pattern) {
		Boolean[][] anses = new Boolean[N][N];
		for (int i = 0; i < N; ++i) {
			Arrays.fill(anses[i], null);
		}
		boolean[] pat = new boolean[N];
		int honestCount = 0;
		for (int i = 0; i < N; ++i) {
			boolean isHonest = (1 == (pattern & 1));
			pat[i] = isHonest;
			if (isHonest) {
				++honestCount;
			}
			for (int j = 0; j < N; ++j) {
				if (answers[i][j] != null) {
					if (isHonest) {
						anses[i][j] = answers[i][j];
					}
				}
			}
			pattern = pattern >> 1;
		}
		// 矛盾がないか調べる
		boolean isOK = true;
		for (int j = 0; j < N; ++j) {
			boolean ok = true;
			for (int i = 0; i < N; ++i) {
				if (anses[i][j] != null) {
					if (anses[i][j] != pat[j]) {
						// 誤り
						ok = false;
						break;
					}
				}
			}
			if (!ok) {
				// 矛盾する結果が1つでも含まれていた
				isOK = false;
				break;
			}
		}
		if (isOK) {
			return honestCount;
		} else {
			return 0;
		}
	}

	void showResult() {
		System.out.println(result);
	}
}

Measured memory_bytes: 42696
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define pi 3.1415926535897
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define inf 1000000000000000000
#define inf1 1000000000
#define endl '\n'
ll n,m;
vector<ll> adj[100005];
ll dp_d[100005];
ll dp_u[100005];
void dfs(ll v,ll p)
{
	ll ans=1;
	for(auto it:adj[v])
	{
		if(it!=p)
		{
			dfs(it,v);
			ans=(ans*(dp_d[it]+1))%m;
		}
	}
	dp_d[v]=ans;
	return;
}
void dfs1(ll v,ll p)
{
	ll a=dp_u[v];
	for(auto it:adj[v])
	{
		if(it!=p)
		{
			dp_u[it]=(dp_u[it]*a)%m;
			a=(a*(1+dp_d[it]))%m;
		}
	}
	reverse(adj[v].begin(),adj[v].end());
	a=1;
	for(auto it:adj[v])
	{
		if(it!=p)
		{
			dp_u[it]=(dp_u[it]*a)%m;
			a=(a*(1+dp_d[it]))%m;
		}
	}
	for(auto it:adj[v])
	{
		if(it!=p)
		{
			dp_u[it]++;
			dfs1(it,v);
		}
	}
	return;
}
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	cin>>n>>m;
	for(ll i=1;i<n;i++)
	{
		ll a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	for(ll i=1;i<=n;i++)
		dp_u[i]=1;
	dfs(1,-1);
	dfs1(1,-1);
	for(ll i=1;i<=n;i++)
		cout<<(dp_u[i]*dp_d[i])%m<<endl;
	return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x, y;
	cin >> x >> y;
	bool ok = false;
	for (int i = 0; i <= x; i++) {
		int a = i;
		int b = x - i;
		if (2 * a + 4 * b == y || 4 * a + 2 * b == y) {
			ok = true;
			break;
		}
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
	int N;
	scanf("%d", &N);
	char* key[N];
	int score[N];
	for (int i = 0; i < N; i++) {
		char* _key = malloc(11);
		scanf(" %s", _key);
		for (int j = 0; j < i; j++) {
			if (!strcmp(key[j], _key)) {
				key[i] = "";
				score[i] = 0;
				score[j]++;
				goto CONTINUE;
			}
		}
		key[i] = _key;
		score[i] = 1;
		CONTINUE:;
	}

	int M;
	scanf("%d", &M);
	for (int i = 0; i < M; i++) {
		char _key[11];
		scanf(" %s", _key);
		for (int j = 0; j < N; j++) {
			if (!strcmp(key[j], _key)) {
				score[j]--;
				if (score[j] == 0) {
					key[j] = "";
				}
			}
		}
	}

	int max = 0;
	for (int i = 0; i < N; i++) {
//		printf("%s %d\n", key[i], score[i]);
		if (max < score[i]) {
			max = score[i];
		}
	}
	printf("%d\n", max);

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

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

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

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

int gcd(int a, int b) {
  if (a < b) { swap(a, b); }
  if (b == 0) { return a; }
  return gcd(b, a % b);
}

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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

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

int MSB(int n) {
  int r = -1;
  for (; n > 0; n >>= 1) {
    ++r;
  }
  return r;
}

int main(int argc, char** argv) {
  int N;
  cin >> N;

  if (!(N & N - 1)) { // N is 2 ** x
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  cout << 1 + N << " " << 3 + N << endl;
  for (int i = 2; i < N + 1; ++i) {
    if (N % 2 == 0 && i == N) {
      int t = 1 << MSB(N);
      cout << N << " " << t << endl;
      cout << N + N << " " << (t ^ N ^ 1) << endl;
    } else {
      cout << 1 << " " << i << endl;
      cout << i << " " << (i ^ 1) + N << endl;
    }
  }
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    ll a[3], b[3];
    cin >> n;
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    for(int i = 0; i < 3; i++){
        cin >> b[i];
    }
    ll maxa2b = n;
    for(int x = 0; x <= n; x++){
        if(a[0] * x > n) break;
        for(int y = 0; y <= n; y++){
            if(a[1] * y > n - a[0] * x) break;
            int z = (n - a[0] * x - a[1] * y) / a[2];
            ll change = b[0] * x + b[1] * y + b[2] * z + (n - a[0] * x - a[1] * y) % a[2];
            maxa2b = max(maxa2b, change);
        }
    }
    ll maxb2a = maxa2b;
    if(a[0] < b[0] && a[1] < b[1] && a[2] < b[2]){
        cout << maxb2a << endl;
        return 0;
    }
    if(a[0] < b[0]){
        for(int y = 0; y <= maxa2b; y++){
            if(b[1] * y > maxa2b) break;
            int z = (maxa2b - b[1] * y) / b[2];
            ll change = a[1] * y + a[2] * z + (maxa2b - b[1] * y) % b[2];
            maxb2a = max(maxb2a, change);
        }
        cout << maxb2a << endl;
        return 0;
    }
    if(a[1] < b[1]){
        for(int x = 0; x <= maxa2b; x++){
            if(b[0] * x > maxa2b) break;
            int z = (maxa2b - b[0] * x) / b[2];
            ll change = a[0] * x + a[2] * z + (maxa2b - b[0] * x) % b[2];
            maxb2a = max(maxb2a, change);
        }
        cout << maxb2a << endl;
        return 0;
    }
    if(a[2] < b[2]){
        for(int y = 0; y <= maxa2b; y++){
            if(b[1] * y > maxa2b) break;
            int x = (maxa2b - b[1] * y) / b[0];
            ll change = a[1] * y + a[0] * x + (maxa2b - b[1] * y) % b[0];
            maxb2a = max(maxb2a, change);
        }
        cout << maxb2a << endl;
        return 0;
    }
    for(int x = 0; x <= maxa2b; x++){
        if(b[0] * x > maxa2b) break;
        for(int y = 0; y <= maxa2b; y++){
            if(b[1] * y > maxa2b - b[0] * x) break;
            int z = (maxa2b - b[0] * x - b[1] * y) / b[2];
            ll change = a[0] * x + a[1] * y + a[2] * z + (maxa2b - b[0] * x - b[1] * y) % b[2];
            maxb2a = max(maxb2a, change);
        }
    }
    cout << maxb2a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    cin >> n;
    vector<ll> a(n,0);
    rep(i,n)cin >> a.at(i);
    ll ans = 0;
    while(1){
        rep(i,n){
            if(a[i]%2 == 1){
                cout << ans << endl;
                return 0;
            }else{
                a[i]/=2;
            }
        }
        ans++;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 764
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////

int main() {
ll ans = 0;
	int N;
	ll a,b;
	cin >> N >> a;
	rep(i,N-1)
	{
		cin >> b;
		a = gcd(b,a);
	}
	ans = a;

	cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.nextLine().toCharArray();
        int n = S.length;

        for (int i = 0; i < (1 << n - 1); i++) {
            Queue<String> queue = new LinkedList<>();

            // char -> long
            long sum = (S[0] - '0');
            queue.add(String.valueOf(S[0]));
            for (int j = 0; j < n - 1; j++) {
                if ((i & (1 << j)) != 0) {
                    sum += S[j + 1] - '0';
                    queue.add("+");
                } else {
                    sum -= S[j + 1] - '0';
                    queue.add("-");
                }
                queue.add(String.valueOf(S[j + 1]));
            }

            if (sum == 7) {
                while(!queue.isEmpty()) {
                    System.out.print(queue.remove());
                }
                System.out.print("=7");
                return;
            }
        }
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;string s;
	cin>>s;k=s.size();
	int cnt=15-k;
	for(int i=0;i<(int)s.size();i++) cnt+=s[i]=='o';
	if(cnt>=8) puts("YES");else puts("NO");
}

Measured memory_bytes: 3588
import collections
s = list(input())
n = len(s)
mod = [0]*(n+1)
pow10 = 1
for i in range(n):
    mod[i+1] = (mod[i] + int(s[-1-i])*pow10)%2019
    pow10 = pow10*10%2019
d = collections.Counter(mod)
ans = 0
for i in d.values():
    ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 79548
#include <bits/stdc++.h>
using f32 = float;
using f64 = double;
using f80 = __float80;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<LL>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
signed main() {
int a=0,b,c,n;
string s,t;
cin >> s >> t;
REP(i,s.size()){
if(s[i]!=t[i])a++;
}
 cout <<a;
}

Measured memory_bytes: 3916
import java.util.Scanner;

public class Main {
    static int ans;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double EPS = 1e-10;
        while (true) {
            int m = sc.nextInt();
            if (m == 0)
                break;
            int[] vs = new int[m - 1];
            for (int i = 0; i < m - 1; i++) {
                vs[i] = sc.nextInt();
            }
            int n = sc.nextInt();
            int[] us = new int[n - 1];
            for (int i = 0; i < n - 1; i++) {
                us[i] = sc.nextInt();
            }
            double a1 = calcArea(vs);
            double a2 = calcArea(us);
            if (Math.abs(a1 - a2) < EPS)
                System.out.println(0);
            else if (a1 > a2)
                System.out.println(1);
            else
                System.out.println(2);
        }
    }

    public static double calcArea(int vs[]) {
        double area = 0;
        int sum = 0;
        for (int i = 0; i < vs.length; i++) {
            area += Math.abs(Math.sin(Math.PI * vs[i] / 180)) / 2;
            sum += vs[i];
        }
        area += Math.abs(Math.sin(Math.PI * (360 - sum) / 180)) / 2;
        return area;
    }
}

Measured memory_bytes: 12000
import sys
import numpy as np
from collections import Counter

read = sys.stdin

N, K = map(int, read.readline().split())
k = 2 * K
xyc = np.array(read.read().split(), np.str).reshape(-1, 3)
x = xyc[:, 0].astype(int)
y = xyc[:, 1].astype(int)
c = xyc[:, 2]

x = np.where(c == 'B', x - K, x)
x %= k
y %= k

'''
# grid[[1,2],[1,2]]+=1 としてもgrid[1,2]=1であり重複は考慮されない。
# uniqueを使って(x,y)の重複をカウントする
# return_countはver1.9からだった・・・ ダメじゃん
xy, cnt = np.unique(x + y * 10000, return_counts=True)
x = xy % 10000
y = xy // 10000
'''
xy = Counter(list(zip(x, y)))
cnt = np.array(list(xy.values()), np.int64)
xy = np.array(list(xy.keys()), np.int64)
x = xy[:, 0]
y = xy[:, 1]

grid = np.zeros((3 * K, 3 * K), np.int64)
grid[x, y] += cnt
grid[x + K, y + K] += cnt
grid[x + K, y] -= cnt
grid[x, y + K] -= cnt
np.cumsum(grid, axis=0, out=grid)
np.cumsum(grid, axis=1, out=grid)

p1 = grid[:K, :K] + grid[k:, k:] + grid[K:k, K:k] + grid[k:, :K] + grid[:K, k:]
p2 = grid[K:k, :K] + grid[K:k, k:] + grid[:K, K:k] + grid[k:, K:k]
print(max(p1.max(), p2.max()))


Measured memory_bytes: 134160
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        h: u64,
        w: u64,
    }
    let ans = if h == 1 || w == 1 {
        1
    } else if w % 2 == 0 {
        (w / 2) * h
    } else if h % 2 == 0 {
        (h / 2) * w
    } else {
        h * w - h * w / 2
    };
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	int nth = n%10;
  	if(nth==3)cout<<"bon\n";
  	else if(nth==0 || nth ==1 || nth ==6 || nth==8)cout<<"pon\n";
  	else cout<<"hon\n";
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
    int a,b,c,i,A,S;
    cin>>a>>b>>c;
    S=0;
    for(i=a;i<=b;i++){
        A=c%i;
        if(A==0){S=S+1;}
        }
    cout<<S<<endl;
    
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int maisu,i,alice,bob;
  cin>>maisu;
  vector<int>card(maisu);
  for(i=0;i<maisu;i++)
    cin>>card.at(i);
  for(i=0;i<maisu-1;i++){
    for(int i2=maisu-1;i2>i;i2--){
      if(card.at(i2)<card.at(i2-1)){
        int temp=card.at(i2);
        card.at(i2)=card.at(i2-1);
        card.at(i2-1)=temp;
      }
    }
  }
    for(i=1;i<maisu;i+=2)
      alice+=card.at(i);
    for(i=0;i<maisu;i+=2)
      bob+=card.at(i);
    if(maisu%2==1){
       int temp=alice;
      alice=bob;
      bob=temp;
    }
    cout << alice-bob <<endl;
   
  
     
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



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

  vector<int> to_e(n), to_w(n);

  // 右側を向かせる人数
  int t = 0;
  rep(i, n) {
    if(s[i] == 'W') t++;
    to_e[i] = t;
  }

  // 左側を向かせる人数
  t = 0;
  rrep(i, n) {
    if(s[i] == 'E') t++;
    to_w[i] = t;
  }

  int ans = min(to_w[1], to_e[n-2]);
  rep1(i, n-1) {
    ans = min(ans, to_e[i-1] + to_w[i+1]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3076
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

main = do
  [n] <- getInts
  s <- B.getLine
  print $ fst $ B.foldl f (0,0) s
  where
    c2i 'I' = 1
    c2i _ = -1
    f (mx,x) c = (max mx (x + c2i c), x + c2i c)

-- util
getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

substr :: Int -> Int -> B.ByteString -> B.ByteString
substr b l s = B.take l $ B.drop b s


Measured memory_bytes: 508
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		List<Integer> list = new ArrayList<>(3);
		for (int i = 0; i < 3; ++i) {
			list.add(Integer.parseInt(tokens[i]));
		}
		int K = Integer.parseInt(in.readLine());
		Collections.sort(list);
		int result = list.get(0) + list.get(1);
		result += Math.pow(2, K) * list.get(2);
		System.out.println(result);

	}

	void calc() {
	}

	void showResult() {
	}
}

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

int main(){
  int N;
  cin >> N;
  int n7 = 0;//7ドルのお菓子の個数
  bool ans = false;
  while((N -7*n7) >= 0){
    if((N - 7*n7) % 4 == 0){
      ans = true;
      break;
    }
    n7++;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		int temp = 0;
		for (int j = 'a'; j <= 'z'; j++) {
			bool firstflag = false, secondflag = false;
			for (int k = 0; k <= i; k++) {
				if (s[k] == j) {
					firstflag = true;
					break;
				}
			}
			for (int k = i + 1; k < n; k++) {
				if (s[k] == j) {
					secondflag = true;
					break;
				}
			}
			if (firstflag && secondflag) {
				temp++;
			}
		}
		if (temp > ans)
			ans = temp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Scanner;


public class Main {

	/**
	 * problem solver
	 */
	public static class Problem {

		/**
		 * paramters
		 */
		private int n;
		private int m;
		private ArrayList<Long> a;
		private ArrayList<Long> c;
		private ArrayList<Integer> b;

		/**
		 * constructor
		 */
		Problem() {
			a = new ArrayList<Long>();
			c = new ArrayList<Long>();
			b = new ArrayList<Integer>();
			n = 0;
			m = 0;
		}

		/**
		 * standard input
		 */
		void input() {
			Scanner sc = new Scanner(System.in);
			n = sc.nextInt();
			m = sc.nextInt();

			for (int i = 0; i < n; i++) {
				a.add(sc.nextLong());
			}
			
			for (int i = 0; i < m; i++) {
				b.add(sc.nextInt());
				c.add(sc.nextLong());
			}
			sc.close();
		}


		public static class Bc implements Comparable<Bc>, Serializable {

			private static final long serialVersionUID = 7126883977005996870L;

			public int b;
			public long c;

			Bc(int b, long c) {
				this.b = b;
				this.c = c;
			}

//            @Override
//            public int hashCode() {
//            	return Objects.hash(t,d);
//            }

			@Override
			public boolean equals(Object other) {
				if (other == this) {
					return true;
				}

				if (other instanceof Bc) {
					Bc that = (Bc) other;
					return Objects.equals(that.b, this.b) && Objects.deepEquals(that.c, this.c);
				}
				return false;
			}

			@Override
			public int compareTo(Bc that) {
				Comparator<Long> naturalOrder = Comparator.naturalOrder();
				return Objects.compare(this.c, that.c, naturalOrder);
			}

			@Override
			public String toString() {
				Object[] params = { b, c };
				MessageFormat mf = new MessageFormat("({0},{1})");
				return mf.format(params);
			}
		}
		

		/**
		 * solver
		 */
		void solve() {
			PriorityQueue<Long> pque = new PriorityQueue<>();
			ArrayList<Bc> bcs = new ArrayList<>();
			ArrayList<Long> candidates = new ArrayList<>();

			for (Long e : a) {
				pque.add(e);
			}
			
			for (int i =0; i < m;i++) {
				Bc bc = new Bc(b.get(i), c.get(i));
				bcs.add(bc);				
			}
			
			Collections.sort(bcs, Collections.reverseOrder());
			
			
			for(Bc bc : bcs) {
				for(int i=0;i<bc.b;i++) {
					candidates.add(bc.c);
					
					if(candidates.size() == n) {
						break;
					}
				}
				if (candidates.size() == n) {
					break;
				}
			}

			for(long l: candidates) {
				long amin = pque.peek();
				if (amin < l) {
					pque.poll();
					pque.add(l);
				}
			}
			
			
			long ans = 0;
			for (long e: pque) {
				ans += e;
			}
			
			System.out.println(ans);

		}

	}

	public static void main(String args[]) {

		Problem p = new Problem();

		p.input();

		p.solve();
	}
}


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


int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int sum =A+B+C;
  int ans =0;
  while(1){
    if(sum%3==0&&(sum/3)>=max(A,max(B,C))){
      break;
    }
    sum+=2;
    ans++;
  }
cout<<ans<<endl;

}


Measured memory_bytes: 256
import heapq
from itertools import repeat, starmap
from operator import mul

R = lambda: map(int, input().split())
n, m = R()
a = list(zip(R(), repeat(1)))
heapq.heapify(a)
for _ in range(m):
    b, c = R()
    i = b
    while i:
        x, y = a[0]
        if x >= c:
            break
        heapq.heappop(a)
        d = min(i, y)
        i -= d
        y -= d
        if y:
            heapq.heappush(a, (x, y))
    heapq.heappush(a, (c, b - i))
print(sum(starmap(mul, a)))


Measured memory_bytes: 21548
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long;


int main()
{

	int H, W;

	cin >> H >> W;

	int n1 = 0, n2 = 0, n4 = H*W;


	if (H % 2 == 1) { n4 -= W; n2 += W; }

	if (W % 2 == 1) { n4 -= H; n2 += H; }

	if (H % 2 == 1 && W % 2 == 1) { n2 -= 2; n1 += 1; n4 += 1; }

	map<char, int> map;

	for (int h = 0; h < H; ++h)
	{

		string S; cin >> S;

		for (int w = 0; w < W; ++w)
		{

			char c = S[w];

			auto itr = map.find(c);

			if (itr != map.end())
			{
				map[c]++;
			}
			else
			{
				map[c] = 1;
			}

		}

	}

	int a_n1 = 0, a_n2 = 0, a_n4 = 0;

	for (auto itr = map.begin(); itr != map.end(); ++itr)
	{

		a_n4 += itr->second / 4;
		itr->second = itr->second % 4;

		a_n2 += itr->second / 2;
		a_n1 += itr->second % 2;

	}

	if (n1 == a_n1&&n2 == a_n2 * 2 && n4 == a_n4 * 4)
	{

		cout << "Yes" << endl;

	}

	else 
	{
		for(;a_n4*4>n4;)
		{
			a_n4--;
			a_n2 += 2;
			if (n1 == a_n1&&n2 == a_n2 * 2 && n4 == a_n4 * 4)
			{

				cout << "Yes" << endl;

				return 0;
			}
		}

		cout << "No" << endl;
	}


	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
#define PI 3.141592653589793238

int a, b, h, m;

void solve() {
  double deg1 = 2 * PI * (60.0 * h + m) / 720.0;
  double deg2 = 2 * PI * 1.0 * m / 60.0;
  double dist = sqrt(a * a + b * b - 2.0 * a * b * (cos(deg1) * cos(deg2) + sin(deg1) * sin(deg2)));
  cout << setprecision(20) << dist << endl;
}

int main() {
  cin >> a >> b >> h >> m;
  solve();
}


Measured memory_bytes: 4172
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

int solve(vector<int> mat){
	if(mat.size() == 1)return mat[0];
	
	vector<int> new_vector;

	rep(i,mat.size()-1){
		new_vector.push_back((mat[i]+mat[i+1])%10);
	}
	return solve(new_vector);
}
int main(){
	char number[15];
	while(scanf("%s",number) != EOF){
		vector<int> mat;
		rep(i,10){
			mat.push_back(number[i]-48);
		}
			
		printf("%d\n",solve(mat));
	}
	return 0;
}

Measured memory_bytes: 1184
/*input
ant
obe
rec
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii; 


#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 


ll gcd(ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
} 

ll lcm(ll fir, ll sec){
    return (fir*sec)/(gcd(fir, sec));
}

//x^n%M
// log(n) time, log(n) memory
ll modularExponentiation(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}

const int MOD = 1e9 + 7;
const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';


// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    cout<<a[0]<<b[1]<<c[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
    int a;
    cin>>a;
    set<int > s1,c;
    set<int > s2;
    while (a--)
    {
        int t;
        cin>>t;
        s1.insert(t);
    }
    cin>>a;
    while (a--)
    {
        int t;
        cin>>t;
        s2.insert(t);
    }

    set_difference(s1.cbegin(),s1.end(),s2.begin(),s2.end(),inserter(c,c.begin()));

    auto it=c.begin();
    auto its=c.end();
    for (auto i = it; i !=its ; ++i)
    {
        cout<<*i<<endl;
    }

}


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

N_1 = N - 1
counts = 0
i = 1
j = 1
while i <= N_1:
    while j <= N_1:
        if i * j <=  N_1:
            counts = counts + 1
        else:
            j = N_1
        j = j + 1
    j = 1
    i = i + 1

print(counts)

Measured memory_bytes: 67196
N,K=map(int, input().split())
h=list(map(int,input().split()))
dp=[float('inf') for i in range(N)]
dp[0]=0
if(N<K):
  K=N-1
for i in range(1,N):
  for j in range(1,K+1):
    dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[N-1])

Measured memory_bytes: 56928
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;
#define MX 200



int main()
{
int a;
cin >> a;
if (a / 10 == 9 || a % 10 == 9)
cout << "Yes";
else cout << "No";
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
//小さいほうから取り出すpriority queue
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
typedef pair<int, int>P;

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


long long nCr(long long n, long long r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	long long i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}	
signed main() {

	ll N; cin >> N;
	ll ans = 0;
	for (int k = 1; k*k <= N+1; k++) {
		if (N%k == 0 && (N - k) / k > k) {
			ans += (N - k) / k;
		}
	}

	print(ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n;cin>>n;
    string a[n];for (int i=0;i<n;i++)cin>>a[i];
    string d[n];for(int i=0;i<n;i++)d[i]=a[i];
    int c=0;
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if (a[j][1]<a[j-1][1]){
                string b=a[j];a[j]=a[j-1]; a[j-1]=b;
            }
        }
        
    }
    for (int k=0;k<n-1;k++){cout<<a[k]<<" ";}cout<<a[n-1]<<endl;
    cout<<"Stable"<<endl;
    
    for (int i=0;i<n;i++){
        int minj=i;
        for (int j=i;j<n;j++){
            if(d[j][1]<d[minj][1]){
                minj =j;
            }
            
        }string b=d[i];d[i]=d[minj];d[minj]=b;
    }
    string s="Stable";
     for(int i=0;i<n;i++){
         if (a[i]!=d[i]){
             s="Not stable";
         }
     }
      for (int k=0;k<n-1;k++){cout<<d[k]<<" ";}cout<<d[n-1]<<endl;
        cout<<s<<endl;
   
    
}


Measured memory_bytes: 3228
n = int(input())
s = [int(input()) for _ in range(n)]

total = sum(s)
l = [i for i in s if i%10 != 0]
l.sort()

if total%10 != 0:
    print(total)
else:
    if len(l) == 0:
        print(0)
    else:
        print(total - l[0])

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int minValue = Integer.MAX_VALUE;
        // abピザでループ
        for (int i = 0; i <= 100000; i++) {
            // abピザ = C * 2 * i;
            int valueC = C * 2 * i;
            int remainX = Math.max(X - i, 0);
            int valueA = remainX * A;
            int remainY = Math.max(Y - i, 0);
            int valueB = remainY * B;

            minValue = Math.min(minValue, valueA + valueB + valueC);
        }

        System.out.println(minValue);
    }
}

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

using namespace std;

typedef long long int64;

const int64 INF = 1LL << 58;

vector< int > g[150000];
double dp1[150000];
double dp2[150000];

double dfs(int idx, int par = -1)
{
  dp1[idx] = 0;
  int child = 0;
  for(auto &to : g[idx]) {
    if(to == par) continue;
    ++child;
  }
  for(auto &to : g[idx]) {
    if(to == par) continue;
    dp1[idx] += (dfs(to, idx) + 1) / child;
  }
  return (dp1[idx]);
}

void dfs2(int idx, double beet = 0, int par = -1)
{
  int child = 0;
  double latte = 0;

  for(auto &to : g[idx]) {
    if(to == par) continue;
    ++child;
    dp2[idx] += (dp1[to] + 1) / g[idx].size();
  }
  for(auto &to : g[idx]) {
    if(to == par) continue;
    if(g[idx].size() - 1 == 0) latte += dp1[to] + 1;
    else latte += (dp1[to] + 1) / (g[idx].size() - 1);
  }

  if(~par) dp2[idx] += (beet + 1) / g[idx].size();
  if(~par) {
    if(g[idx].size() - 1 == 0) latte += beet + 1;
    else latte += (beet + 1) / (g[idx].size() - 1);
  }

  if(child == 0) return;
  for(auto &to : g[idx]) {
    if(to == par) continue;
    dfs2(to, latte - (g[idx].size() - 1 == 0 ? dp1[to] + 1 : (dp1[to] + 1) / (g[idx].size() - 1)), idx);
  }
}


int main()
{
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0);
  dfs2(0);
  for(int i = 0; i < N; i++) {

    cout << fixed << setprecision(10) << dp2[i] << endl;
  }
}



Measured memory_bytes: 17408
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char ss[1005];
int n,e,s,w;

int main() {
    while(1==scanf("%s",ss)) {
        n=e=s=w=0;
        for(int i=0;ss[i]!='\0';++i) {
            if(ss[i]=='N') {
                n=1;
            }
            else if(ss[i]=='E') {
                e=1;
            }
            else if(ss[i]=='S') {
                s=1;
            }
            else {
                w=1;
            }
        }
        printf("%s\n",(n^s)==0&&(e^w)==0?"Yes":"No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,A,B;
  cin >> N>>A>>B;
  long C = N/(A+B);
  long D = N%(A+B);
  long ans;
  if(D>A){
    ans = C*A +A;
  }
  else{
    ans = C*A +D;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

vector<long double> A;
int N;

void solve() {
	cin >> N;
	A.resize(N);
	for (int n = 0; n < N; n++)cin >> A[n];
	sort(A.begin(), A.end(),greater<long double>());
	long double ans = (A[N - 1] + A[N - 2]) / 2;
	for (int n = N - 3; n >= 0; n--) {
		ans = A[n] / 2 + ans / 2;
	}
	cout << setprecision(12) << ans << endl;
	return;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        double D = scan.nextInt();
        double T = scan.nextInt();
        double S = scan.nextInt();
        double time = D / S;
        if (time <= T) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 35652
#include<bits/stdc++.h>
using namespace std;
#define ll long long 

#define F first
#define S second

int dx[] = { 0 , 0, 1, -1, -1, -1, 1, 1};
int dy[] = { 1, -1 , 0, 0, 1, -1, 1, -1};
const double EPS= 1e-8 ;
const double PI  = acos(-1.0);
#define inf INT_MAX
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }





int main()
 {
 int n ; 
 cin>>n ; 
 int a[n] ; 
 for ( int i = 0 ; i< n;i++) cin>>a[i] ; 
 vector < int > dp ( n , inf) ; 
 dp[0]=0; 
 dp[1]= abs ( a[1] -a[0]) ;   
 for ( int i = 2 ; i<n  ;i++) 
  
 {
	 
	 dp[i]= min ( dp[i-2]+abs( a[i-2]-a[i]), dp[i-1]+abs( a[i-1]-a[i])) ; 
 } 
cout<< dp [ n-1] << endl; 


 return 0 ;
}






 
 
 
 
 
 

 


Measured memory_bytes: 1024
/*RUSTAM1111 🦁🦁🦁💪💪💪😎😎😎🔥🔥🔥🔥⚔️⚔️⚔️*/
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int z = 0;
	int a, b;
	cin>>a>>b;
	int ar[a];
	for(int i = 0; i<a; i++)
	{
		cin>>ar[i];
	}
	sort(ar, ar+a);
	for(int i = 0; i<b; i++)
	{
		z+=ar[i];
	}
	cout<<z<<endl;
}
/*RUSTAM1111 🦁🦁🦁💪💪💪😎😎😎🔥🔥🔥🔥⚔️⚔️⚔️*/


Measured memory_bytes: 3572
#include<stdio.h>
int main()
{
  int i,j=0,k=0;
  char str[200]={};
  scanf("%s",str);
  for(i=0;i<=3;i++){
    if('S'==str[i]){
      j=j+1;
    }
  }
  for(i=0;i<=3;i++){
    if('R'==str[i]){
      k=k+1;
    }
  }
   if(j==3){
     printf("0");
       return 0;
   }
  if(str[1]=='S'&& str[0]=='R'|| str[3]=='R'){
    printf("1");
  }
  else{
    printf("%d",k);
  }
  return 0;
}

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

string s;
bool yymm,mmyy;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>s;
    if((s[0]-'0')*10+s[1]-'0'<=12&&(s[0]-'0')*10+s[1]-'0'>=1)mmyy=true;
    if((s[2]-'0')*10+s[3]-'0'<=12&&(s[2]-'0')*10+s[3]-'0'>=1)yymm=true;
    if(yymm&&mmyy){
        cout<<"AMBIGUOUS"<<endl;
        return 0;
    }
    if(yymm){
        cout<<"YYMM"<<endl;
        return 0;
    }
    if(mmyy){
        cout<<"MMYY"<<endl;
        return 0;
    }
    cout<<"NA"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
const int nmax=100005;
struct edg
{
    int a,b,c;
}v[nmax];
long long sum[nmax],w[nmax];
int tt[2*nmax],rg[2*nmax],apm[nmax],mare[nmax],valid[nmax];
int n,m,i,j,ans,poz;
vector<int> ad[nmax];
bool comp(edg unu,edg doi)
{
    return unu.c<doi.c;
}
int finds(int x)
{
    while(x!=tt[x])
        x=tt[x];
    return x;
}
set<int> h[nmax];
set<int>::iterator it;
void unite(int A,int B)
{
    if(rg[A]<rg[B]) swap(A,B);
    tt[B]=A;ad[A].push_back(B);
    sum[A]+=sum[B];rg[A]+=rg[B];
    for(it=h[B].begin();it!=h[B].end();it++)
        h[A].insert(*it);
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    for(i=1;i<=n;i++)
        cin>>w[i];
    for(i=1;i<=m;i++)
    {
        cin>>v[i].a>>v[i].b>>v[i].c;
    }
    sort(v+1,v+m+1,comp);
    for(i=1;i<=n;i++)
        sum[i]=w[i],tt[i]=i,rg[i]=1;
    for(i=1;i<=m;i++)
    {
        if(finds(v[i].a)!=finds(v[i].b))
        {
            unite(finds(v[i].a),finds(v[i].b));
            if(sum[finds(v[i].a)]>=1LL*v[i].c)
            {
                valid[i]=1;poz=finds(v[i].a);
                while(!h[poz].empty())
                {
                    valid[(*h[poz].begin())]=1;
                    h[poz].erase(h[poz].begin());
                }
            }
            else
            {
                h[finds(v[i].a)].insert(i);
            }
        }
    }
     for(i=1;i<=n;i++)
        sum[i]=w[i],tt[i]=i,rg[i]=1;
    for(i=1;i<=m;i++)
    {
        if(finds(v[i].a)!=finds(v[i].b)&&valid[i])
            unite(finds(v[i].a),finds(v[i].b));
    }
    long long sumtot;
    ans=m;
    for(i=1;i<=m;i++)
       if(finds(v[i].a)==finds(v[i].b)&&sum[finds(v[i].a)]>=v[i].c)
         ans--;
    cout<<ans;
    return 0;
}


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


int main() {

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    int m;
    cin >> m;
    vector<string> t(m);
    rep(i, m) cin >> t[i];
    int mx = 0;
    rep(i, n) {
        int cnt = 0;
        int c = 0;
        rep(j, n) {
            if (s[i] == s[j]) ++cnt;
        }
        rep(k, m) {
            if (s[i] == t[k]) ++c;
        }
        mx = max(mx, cnt - c);
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
//B - Choose Integers: 
//Assunto: 
#include<bits/stdc++.h>
#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 loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int a, b, c, aux, t = 1000;
    bool ans = false;
    cin >> a >> b >> c;
    if(a == b) {
        if(c == 0) ans = true;
    } else {
        aux = a;
        while(t--) {
            if(aux % b == c) ans = true;
            //cout << aux % b << " ";
            aux += a;
        } //cout << "\n";
    }
    if(ans) cout << "YES\n";
    else cout << "NO\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[101][100010];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            dp[i+1][j] = dp[i][j];
            if (j >= w[i]) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }
    printf("%lld\n", dp[N][W]);
    return 0;
}

Measured memory_bytes: 78464