akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int64_t n, m;

void read()
{
	cin >> n >> m;
}

void solve()
{
	if(n == 1 && m == 1) cout << 1 << endl;
	else if(n == 1) cout << m - 2 << endl;
	else if(m == 1) cout << n - 2 << endl;
	else cout << (n - 2) * 1ll * (m - 2) << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}



Measured memory_bytes: 256
N = int(input())
S1 = input()
S2 = input()
ans = 1
mod = 10**9+7
cnt = 0
former = 0 #0が縦、1が横
 
if S1[0] == S2[0]:
    cnt += 1
    ans = 3
    former = 0
else:
    cnt += 2
    ans = 6
    former = 1
 
while cnt < N:
    if S1[cnt] == S2[cnt]:
        if former:
            ans *= 1
        else:
            ans *= 2
        ans %= mod
        former = 0
        cnt += 1
    else:
        if former:
            ans *= 3
        else:
            ans *= 2
        former = 1
        cnt += 2
        ans %= mod
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	int count_alf = 0,C = 0;
	bool top_A = false;
	cin >> s;
	if (s.at(0) == 'A')top_A = true;
	for (int i = 1; i < (int)s.size(); i++) {
		if (2 <= i && i < (int)s.size() - 1 &&s.at(i) == 'C')C++;
		if ('a' <= s.at(i) && s.at(i) <= 'z') count_alf++;
	}
	if (top_A && C == 1 && (count_alf + 2) == (int)s.size())cout << "AC" << endl;
	else cout << "WA" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){

  string st;
  int a,b,result,i;

  while(cin>>st){
    if(st[0]=='#') break;
  result=0;
  
  if(st[0]=='y'||st[0]=='u'||st[0]=='i'||st[0]=='o'||st[0]=='p'||st[0]=='h'||st[0]=='j'||st[0]=='k'||st[0]=='l'||st[0]=='n'||st[0]=='m') a=1;
  else a=0;

  for(i=1;i<st.size();i++){

    if(st[i]=='y'||st[i]=='u'||st[i]=='i'||st[i]=='o'||st[i]=='p'||st[i]=='h'||st[i]=='j'||st[i]=='k'||st[i]=='l'||st[i]=='n'||st[i]=='m') b=1;
    else b=0;

    if(a!=b) result++;
    a=b;

  }

  cout<<result<<endl;

  }

  return 0;

}

Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
	int c,b;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(a[i]=='A'){
      c=i;
      break;
    }
  }
  for(int i=a.size()-1;i>=0;i--){
    if(a[i]=='Z'){
      b=i+1;
      break;
    }
  }	
  cout<<b-c<<"\n";
}

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

int main(){
	static int num[1000001],odd[1000001];
	vector<int> pol,podd;
	for(int i = 0;i <= 1000000;i++) odd[i] = i;
	for(int i = 1;;i++){
		int p = i * (i + 1) * (i + 2) / 6;
		if(p > 1000000) break;
		pol.push_back(p);
		num[p] = 1;
		if(p % 2) podd.push_back(p);
	}
	for(int i = 1;i <= 4;i++){
		for(int j = 0;j <= 1000000;j++){
			if(num[j] == i){
				for(int k = 0;k < pol.size();k++){
					if(j + pol[k] <= 1000000) {
						if(!num[j + pol[k]]) num[j + pol[k]] = i + 1;
						else num[j + pol[k]] = min(num[j + pol[k]],i + 1);
					}
				}
			}
		}
	}
	for(int i = 1;i < podd.size();i++){
		for(int j = 0;j <= 1000000;j++){
			if(j + podd[i] > 1000000) break;
			odd[j + podd[i]] = min(odd[j + podd[i]],odd[j] + 1);
		}
	}
	int n;
	while(cin >> n,n){
		cout << num[n] << " " << odd[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 10856
package main

import (
    "fmt"
)

func main() {
    var length int
    var S,T string
  
    fmt.Scan(&length)
    fmt.Scan(&S)
    fmt.Scan(&T)
  
    for i := 0; i < length; i++ {
      fmt.Print(string(S[i])+string(T[i]));
    }
}

Measured memory_bytes: 512
#include<iostream>
#include <queue>
using namespace std;
int main()
{
  int a,b,k,j;
  int q[100];
  j=0;
  cin >> a >> b >> k;
  for(int i=a; i>0; --i){
    if((a%i==0)&&(b%i==0))
    {
      q[j]=i;
      j++;
    }else{
    }
  }
  cout << q[k-1];
  return 0;
}

Measured memory_bytes: 256
S = input()
c1 = 0
c2 = 0

for i in range(len(S)):
    if i == 0:
        s1 = '0'
        s2 = '1'
    elif i % 2 == 1:
        s1 += '1'
        s2 += '0'
    else:
        s1 += '0'
        s2 += '1'

for i in range(len(S)):
    if S[i] == s1[i]:
        c2 += 1
    else:
        c1 += 1

print(min(c1, c2))

Measured memory_bytes: 3316
N,K = map(int,input().split())
L = list(map(int,input().split()))

dp = [0 for i in range(N)]

if N < K :
    ans = abs(L[0] - L[N-1])
else :
    for i in range(1,K+1) :
        dp[i] = abs(L[0] - L[i])
    for i in range(K+1,N) :
        cost = float("inf")
        for j in range(i-K,i) :
            calc = dp[j] + abs(L[j] - L[i])
            if cost > calc :
                cost = calc
        dp[i] = cost

    ans = dp[N-1]

print(ans)


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

int main(){
    int n;
    cin>>n;
    if(n>=30)cout<<"Yes\n";
    else cout<<"No\n";
}


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

using namespace std;

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        int _h;
        cin >> _h;
        h[i] = _h;
    }

    vector<int> dp(k + 1);
    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        int c = numeric_limits<int>::max();
        for (int j = 1; j <= min(i, k); j++)
        {
            c = min(c, dp[(i - j) % (k + 1)] + abs(h[i - j] - h[i]));
        }
        dp[i % (k + 1)] = c;
    }
    cout << dp[(n - 1) % (k + 1)] << endl;
}

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


Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;


int main(){
	int N;
	cin>>N;
	int A[N],B[N];
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<N;i++){
		cin>>B[i];
	}
	vector<int> amari;
	long long fusoku=0;
	int ans = 0;
	for(int i=0;i<N;i++){
		if(B[i]>A[i]){
			fusoku+=B[i]-A[i];
			ans++;
		}
		else{
			amari.push_back(A[i]-B[i]);
		}
	}
	sort(amari.begin(),amari.end(),greater<int>());
	int x = 0;
	while(true){
		if(fusoku<=0)break;
		if(x>amari.size()-1)break;
		if(amari[x]==0)break;
		fusoku-=amari[x];
		ans++;
		x++;
	}
	if(fusoku>0)cout<<-1<<endl;
	else cout<<ans<<endl;
		
	
	
	
	return 0;
}


Measured memory_bytes: 1660
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    if(s[0] == s[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
l=[9,900,90000,900000]
n=int(input())
ld=len(str(n))
if ld==1:
  print(n)
elif ld==2:
  print(l[0])
elif ld==3:
  print(l[0]+(n-100)+1)
elif ld==4:
  print(l[0]+l[1])
elif ld==5:
  print(l[0]+l[1]+(n-10000)+1)
elif ld==6:
  print(l[0]+l[1]+l[2])
  


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    string s;
    cin >> s;
    if(s[s.size() - 2] == s[s.size() - 1])
    {
        cout << s.size() - 1 << " " << s.size() << "\n";
        return 0;
    }
    for(int i = 0;i + 2 < s.size();i++)
    {
        if(s[i] == s[i + 1])
        {
            cout << i + 1 << " " << i + 2 << "\n";
            return 0;
        }
        else if(s[i] == s[i + 2])
        {
            cout << i + 1 << " " << i + 3 << "\n";
            return 0;
        }
    }
    cout << "-1 -1\n";

    return 0;
}

Measured memory_bytes: 512
from collections import deque
S = deque(input())
Q = int(input())

a = 0
for i in range(Q):
    t = input()
    if t == "1":
        if a == 0:
            a = 1
        else:
            a = 0
    else:
        t,f,c = t.split()
        if f == "1":
            if a == 0:
                S.appendleft(c)
            else:
                S.append(c)
        else:
            if a == 0:
                S.append(c)
            else:
                S.appendleft(c)
            
if a == 1:
    S = reversed(S)
    
S = ''.join(S)
print(S)

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

  int main(){
    int n;
      cin >> n;
      
    string S = "Christmas";
    string s = " Eve";
    if(n == 25) cout<< S << endl;
    else if(n == 24) cout << S << s << endl;
     else if(n == 23) cout << S + s + s << endl;
     else if(n == 22) cout << S + s + s + s << endl;
    
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;
 int n,m,i;
 cin>>n>>m;
 vector<string>v;
 while(n--)
 {
     cin>>s;
     v.push_back(s);
 }
 sort(v.begin(),v.end());
for(i=0;i<v.size();i++)
{
    cout<<v[i];
}
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>
#include<map>
#include<vector>
#include<cstring>

using namespace std;

int main(){
    char b;
    cin >> b;
    if(b == 'A')cout << 'T';
    else if(b=='T')cout << 'A';
    else if(b=='C')cout << 'G';
    else cout << 'C';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int num = 'a' - 'A';

		char s_1, s_2, s_3;

		s_1 = sc.next().charAt(0);
		s_2 = sc.next().charAt(0);
		s_3 = sc.next().charAt(0);

		sc.close();

		String ans = "";

		ans += (char)(s_1-num);
		ans += (char)(s_2-num);
		ans += (char)(s_3-num);



		System.out.println(ans);

	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <utility>
#include <set>

#define MOD 1000000007

std::vector<int> E_sieve(int max)
{
  std::vector<bool> is_prime(max+1, true);
  is_prime.at(0) = false;
  is_prime.at(1) = false;
  for(int i=2; i<=max/i; i++)
  {
    if(is_prime.at(i))
    {
      for(int j=2; j<=max/i; j++) is_prime.at(i*j) = false;
    }
  }
  std::vector<int> ans;
  for (int i = 0; i <= max; i++)
  {
    if (is_prime.at(i)) ans.push_back(i);
  }
  return ans;
}

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> primes = E_sieve(1000);
  std::vector<int> A(N);
  std::vector<long> total_prime_factor(primes.size(), 0);
  std::set<int> check_others;
  std::vector<int> others;
  std::vector<std::vector<long> > each_prime_factor(N, std::vector<long>(primes.size(), 0));
  for (int i = 0; i < N; i++)
  {
    std::cin >> A.at(i);
    int tmp = A.at(i);
    for (int j = 0; j < primes.size(); j++)
    {
      if (tmp == 1) break;
      int count = 0;
      while (tmp % primes.at(j) == 0)
      {
        tmp /= primes.at(j);
        count++;
      }
      each_prime_factor.at(i).at(j) += count;
      if (total_prime_factor.at(j) < count) total_prime_factor.at(j) = count;
    }
    if (tmp != 1)
    {
      each_prime_factor.at(i).push_back(tmp);
      if (!check_others.count(tmp))
      {
        others.push_back(tmp);
        check_others.insert(tmp);
      }
    }
  }
  long ans = 0;
  for (int i = 0; i < N; i++)
  {
    long tmp = 1;
    for (int j = 0; j < total_prime_factor.size(); j++)
    {
      // std::cout << "check prime factor: x.first = " << x.first << ", x.second = " << x.second << std::endl;
      int num = total_prime_factor.at(j) - each_prime_factor.at(i).at(j);
      while (num)
      {
        tmp *= primes.at(j);
        num--;
        if (tmp > MOD) tmp %= MOD;
      }
    }
    for (int j = 0; j < others.size(); j++)
    {
      long x = others.at(j);
      if (each_prime_factor.at(i).size() == primes.size()+1)
      {
        if (each_prime_factor.at(i).at(primes.size()) == x) continue;
      }
      tmp *= x;
      if (tmp > MOD) tmp %= MOD;
    }
    ans += tmp;
    // std::cout << "check: i = " << i << ", A.at(i) = " << A.at(i) << ", ans = " << ans << std::endl;
    if (ans > MOD) ans %= MOD;
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 27392
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int[] d = new int[6];
		
		Dice dice=new Dice();

		for (int i = 0; i < 6; i++) {
			d[i] = scanner.nextInt();
			dice.num[i]=d[i];
		}
		

		String order = scanner.next();

		dice.Roll(order);


System.out.println(dice.num[0]);
		scanner.close();
	}
}


class Dice {
	int num [];
	Dice(){
		num= new int[6];
	}	
	int box=0;
	
	public void Roll(String order) {
		char[] o = new char[order.length()];

		for (int i = 0; i < order.length(); i++) {

			o[i] = order.charAt(i);

		}
		for(int i = 0; i < order.length(); i++) {

			switch(String.valueOf(o[i])){
			
			case "S" :
				
				box=num[0];
				num[0]=num[4];
				num[4]=num[5];
				num[5]=num[1];
				num[1]=box;
			
				
				break;
				
			case "N" :
				
				box=num[0];
				num[0]=num[1];
				num[1]=num[5];
				num[5]=num[4];
				num[4]=box;
				
				
				break;
				
			case "W" :
				
				box=num[0];
				num[0]=num[2];
				num[2]=num[5];
				num[5]=num[3];
				num[3]=box;
				
				
				break;
				
			case "E":
				

				box=num[0];
				num[0]=num[3];
				num[3]=num[5];
				num[5]=num[2];
				num[2]=box;
				
				
				break;
			
			}


		}
	}


}



Measured memory_bytes: 26184
//21171_somesh || asomesh999

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;

int main()
{
	io
	#ifdef SOMU
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	ll n;
	cin >> n;
	ll minSteps = LONG_MAX;
	for (ll i=1; i <= sqrt(n); i++) 
    { 
        if (n%i == 0) {
            if (n/i == i) 
            	minSteps = min(minSteps, i + i);
            else
            	minSteps = min(minSteps, i + (n / i));
        } 
    }
    cout << minSteps - 2;

	#ifdef SOMU
		cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 1;i <= n;i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func main() {
	sc := NewScanner()

	N := sc.NextInt()
	Q := sc.NextInt()
	dp := make([]bool, N + 1)
	pos := 1
	dp[1] = true
	dp[2] = true
	for i := -1; i <= Q; i++ {
		if 0 <= i && i < Q {
			A, B := sc.NextInt(), sc.NextInt()
			dp[A], dp[B] = dp[B], dp[A]
			if A == pos {
				pos = B
			} else if B == pos {
				pos = A
			}
		}
		if pos >= 2 {
			dp[pos - 1] = true
		}
		if pos < N {
			dp[pos + 1] = true
		}

	}

	count := 0
	for i := 1; i <= N; i++ {
		if dp[i] {
			count++
		}
	}
	fmt.Println(count)

}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	for b > 0 {
		a, b = b, a % b
	}
	return a
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}




Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	vector<int>p(n,0),wa(n,0);
	int q,ac=0,w;
	string tmp;
	rep(i,m){
		cin>>q>>tmp;
		if(p[q-1]==0){
			if(tmp[0]=='W')wa[q-1]+=1;
			else {ac++;w+= wa[q-1];p[q-1]=1;}
		}
	}
	cout<<ac<<' '<<w<<endl;

	
	return 0;
}

Measured memory_bytes: 4028
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s, t; cin >> s >> t;
    int sizeS = s.size(), sizeT = t.size();
    if(sizeS > sizeT) cout << "GREATER" << endl;
    else if(sizeS < sizeT) cout << "LESS" << endl;
    else{
        bool same = 1;
        REP(i ,sizeS) if(s[i] != t[i]) same = 0;
        if(same) cout << "EQUAL" << endl;
        else{
            int topS = s[0] - '0';
            int topT = t[0] - '0';
            cout << (topS > topT ? "GREATER" : "LESS") << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int H, W, D; cin >> H >> W >> D;
  int px[H*W], py[H*W]; 
  int tmp; rep(i, H) rep(j, W) { cin >> tmp; tmp--; px[tmp]=i; py[tmp]=j; }
  int Q; cin >> Q;
  int L[Q], R[Q]; rep(i, Q) { cin >> L[i] >> R[i]; L[i]--; R[i]--; }

  vector<vector<int>> len(D);
  rep(i, D) {
    int t_len = 0;
    len[i].push_back(t_len);
    for(int j=i+D; j<H*W; j+=D) {
      t_len += abs(px[j]-px[j-D]);
      t_len += abs(py[j]-py[j-D]);
      len[i].push_back(t_len);
    }
  }

  rep(i, Q) {
    int m = L[i]%D, ll = L[i]/D, rr = R[i]/D;
    cout << len[m][rr] - len[m][ll] << endl;
  }
  return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct v{
	double x,y,ang;
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<v> p(n);
	rep(i,n){
		cin>>p[i].x>>p[i].y;
		p[i].ang=atan2(p[i].y,p[i].x);
	}
	double ans=0;
	sort(begin(p),end(p),[](const v &a,const v &b){
		return a.ang<b.ang;
	});
	vector<double> angle(2*n);
	rep(i,n){
		angle[i]=p[i].ang;
		angle[i+n]=p[i].ang+2*PI;
	}
	rep(i,n)FOR(j,i,2*n){
		if(angle[j]-angle[i]>PI+EPS) break;
		double nx=0,ny=0;
		FOR(k,i,j+1){
			nx+=p[k%n].x;
			ny+=p[k%n].y;
		}
		chmax(ans,nx*nx+ny*ny);
	}
	cout<<setprecision(15)<<sqrt(ans)<<endl;
}

Measured memory_bytes: 384
object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._

    val Array(n, m) = readLine().split(" ").map(_.toInt)

    // Lを小さい順に並べる
    val LR: Array[(Int, Int)] = (0 until m). map { _ =>
      val Array(l, r) = readLine().split(" ").map(_.toInt)
      (l, r)
    }. toArray. sortBy(_._1)

    // LRの共通領域
    def common(): Int = {
      val reduced = LR reduce { (b, n) =>
        val La = b._1
        val Ra = b._2
        val Lb = n._1
        val Rb = n._2
        if (Lb <= Ra) {
          if (Rb <= Ra) {
            (Lb, Rb)
          } else {
            (Lb, Ra)
          }
        } else {
          return 0
        }
      }
      reduced._2 - reduced._1 + 1
    }

    println(common())
  }

}

Measured memory_bytes: 77092
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
int main(){
  int n; cin>>n;
  vector<P> num;
  for(int i=1;i<n;i++){
    if(n%2==1){
      for(int j=i+1;j<=n;j++){
        if(j==n-i) continue;
        num.push_back(P(i,j));
      }
    }else{
      for(int j=i+1;j<=n;j++){
        if(j==n-i+1) continue;
        num.push_back(P(i,j));
      }
    }
  }
  cout<<num.size()<<endl;
  for(int i=0;i<num.size();i++){
    cout<<num[i].first<<' '<<num[i].second<<endl;
  }
}

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' ';
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 3e5 + 5, M = 3e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
const ll infll = 1e18 + 7;

int q = 1, n, m, k;
int x, y, z;
int ans, cnt, tmp, idx, sum, mn = inf, mx = 0;
int a[N], b[N];
string s, t;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
cin >> n >> q;
while (q--){
    cin >> x >> s;
    if (s == "WA"){
        a[x]++;
    }
    else{
        if (!b[x]){
            b[x] = 1;
            ans++;
            sum += a[x];
        }
    }
}
cout << ans << ' ' << sum << endl;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 3072
#include <stdio.h>

char room[22][22];
int dir_x[] = {0, 1, 0, -1};
int dir_y[] = {-1, 0, 1, 0};

int visit(int x, int y)
{
    int ret = 1;
    room[y][x] = '#';
    int i;
    for(i = 0 ; i < 4; i++){
        if(room[y + dir_y[i]][x + dir_x[i]] != '#')
            ret += visit(x + dir_x[i], y + dir_y[i]);
    }
    return ret;
}

int W, H;

int main(void)
{
    while(1){
        scanf("%d %d", &W, &H);
        if(W == 0 && H == 0)
            break;
        int i, j;

        int x, y;
        for(i = 1; i <= H; i++){
            scanf("%s", &(room[i][1]));
        }
        for(i = 0; i <= H + 1; i++){
            for(j = 0; j <= W + 1; j++){
                if(i == 0 || i == H + 1 || j == 0 || j == W + 1)
                    room[i][j] = '#';
                if(room[i][j] == '@'){
                    x = j;
                    y = i;
                }
            }
        }

        printf("%d\n", visit(x, y));
    }

    return 0;
}

Measured memory_bytes: 620
#include<bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
map<long long, long long> mp;
int main(){
    long long n;
    vector<long long> v;
    cin >> n;
    for(int i = 0; i < n; ++i){
        long long x;
        cin >> x;
        v.push_back(x);
    }
    if(n%2==1){
        for(auto elem: v){
            mp[elem]++;
        }
        if(mp[0]!=1){
            cout << 0 << endl;
            return 0;
        }
        for(int i = 2; i <= n-1; i+=2){
            if(mp[i]!=2){
                cout << 0 << endl;
                return 0;
            }
        }
        long long lol =n/2, ans = 1;
        for(int i = 0; i < lol; ++i){
            ans *= 2;
            ans %= mod;
        } 
        cout << ans << endl;
    } else {
        for(auto elem: v){
            mp[elem]++;
        }
        for(int i = 1; i <= n-1; i+=2){
            if(mp[i]!=2){
                cout << 0 << endl;
                return 0;
            }
        }
        long long lol =n/2, ans = 1;
        for(int i = 0; i < lol; ++i){
            ans *= 2;
            ans %= mod;
        } 
        cout << ans << endl;
    }
}

Measured memory_bytes: 4980
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;



  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define in insert
  #define ld long double


  #define TRACE
  #ifdef TRACE
  #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
  template <typename Arg1>
  void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
  }
  template <typename Arg1, typename... Args>
  void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
  }
  #else
  #define trace(...) 1
  #endif
  template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
  template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
  typedef long long int ll;

  typedef vector<int> vi;
  typedef vector<ll> vl;
  typedef vector<vi> vvi;
  typedef vector<vl> vvl;
  typedef pair<int,int> pii;
  typedef pair<ll,ll> pll;
  typedef vector<pii> vpii;
  typedef vector<pll> vpll;
  const ll mod =1e9+7;
  const ll MAX_NODES =200001;
  const ll MAX_LOG =50;
  const ll maxn = 400000+10;
  #define endl '\n'
  ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
      if (n & 1) res = (res * x) % mod;
      x = (x * x) % mod;
      }
      return res;
  }
  struct DSU{
    vector<int >par,sz;
    DSU(int n)
    {
      par.resize(n);
      sz = vi(n,1);
      iota(par.begin(),par.end(),0);
    }
    int find(int  x){
        if(x==par[x])
          return x;
        return par[x] = find(par[x]);
    }
    void unite(int  a, int  b){
        a = find(a);
        b = find(b);
        if(a==b)
          return ;
        if(sz[a]<sz[b])
          swap(a,b);
        par[b] = a;
        sz[a]+=sz[b];
        return ;
    }

  };
int main()
{

	IOS
	int n,m,k;
	cin>>n>>m>>k;
	DSU fr(n);
	vector<int> g[n],g1[n];
	for(ll i = 0;i<m;i++)
	{
		ll u,v;
		cin>>u>>v;
		u--,v--;
		g[u].pb(v);
		g[v].pb(u);
		fr.unite(u,v);
	}
	for(ll i = 0;i<k;i++)
	{
		ll u,v;
		cin>>u>>v;
		u--,v--;
		g1[u].pb(v);
		g1[v].pb(u);
	}
	for(ll i= 0;i<n;i++)
	{
		int ans = fr.sz[fr.find(i)] - g[i].size()-1;
		for(auto x:g1[i])
		{
			if(fr.find(i) == fr.find(x))
			{
				ans--;
			}
		}
		cout<<ans<<" ";
	}
	


}
 
  


  
  




Measured memory_bytes: 12664
/*

*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <cstdlib>
#include <cmath>
#include <bitset>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb emplace_back
#define fi first
#define se second
#define ld long double
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rf(x) scnaf("%lf",&x)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
#define sz(x) ((int) x.size())
#define ld long double

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

//mt19937 myrand(time(0));
//int get_rand(int n){return myrand()%n + 1;}
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5;

int n,a[N+10],b[3*N+10];

int main(){
    //Open();
    //Close();
    while(~ri(n)){
        rep1(i,1,n) ri(a[i]);
        sort(a+1,a+1+n);
        int tot = 0;
        rep1(i,1,n){
            int j = i;
            while (j+1 <= n && a[j+1]==a[i]){
                j++;
            }
            if (i > 1 && a[i]!=a[i-1]+1){
                tot++;
                b[tot] = 0;
                if (a[i]>a[i-1]+1){
                    tot++;
                    b[tot] = 0;
                }
            }
            b[++tot] = j - i + 1;
            i = j;
        }
        n = tot;
        int num = 0;
        rep1(i,1,n){
            int temp = b[i];
            if (i > 1) temp+=b[i-1];
            if (i < n) temp+=b[i+1];
            num = max(num,temp);
        }
        oi(num);puts("");
    }
    return 0;
}


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

using namespace std;

using ll = long long;

const int dh[] = {1, -1, 0, 0};
const int dw[] = {0, 0, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++) cin >> s[i];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '.') continue;
            bool flag = false;
            for (int k = 0; k < 4; k++) {
                int h = i + dh[k], w = j + dw[k];
                if (h < 0 || h >= H || w < 0 || w >= W) continue;
                if (s[h][w] == '#') {
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
    long long a,b,c,d;cin>>a>>b;c=min(a,b);d=max(a,b);
    for(long long i=c-1;i>0;i--){
        if(c%i==0&&d%i==0){
            c=c/i;
        }
        if(c==1) break;
    }
    long long ans=c*d;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n;
map<int, int> mp;

signed main()
{
	cin >> n;
	REP(i, n){
		int a;
		cin >> a;
		if (mp[a] != 0){
			mp[a] = 0;
		} else {
			mp[a] = 1;
		}
	}

	int cnt = 0;
	for (auto itr = mp.begin(); itr != mp.end(); itr++){
        if (itr-> second == 1){
			cnt++;
		}
    }

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int H, W, K;
int64_t Grid[3005][3005];
int64_t dp[3005][3005][4];

void init()
{
  for (int i = 0; i < 3005; i++)
  {
    for (int j = 0; j < 3005; j++)
    {
      for (int k = 0; k < 4; k++)
      {
        dp[i][j][k] = -1;
      }
    }
  }
}

int main()
{
  cin >> H >> W >> K;
  for (int i = 0; i < K; i++)
  {
    int64_t h, w, v;
    cin >> h >> w >> v;
    Grid[h - 1][w - 1] = v;
  }
  init();
  dp[0][0][0] = 0;
  for (int i = 0; i <= H; i++)
  {
    for (int j = 0; j <= W; j++)
    {
      for (int k = 0; k < 4; k++)
      {
        if (dp[i][j][k] == -1)
          continue;

        if (k < 3)
        {
          dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + Grid[i][j]);
          dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
          dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k] + Grid[i][j]);
        }
        else
        {
          dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
        }
      }
    }
  }
  cout << max(max(dp[H][W][0], dp[H][W][1]), max(dp[H][W][2], dp[H][W][3])) << endl;
}

Measured memory_bytes: 356204
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[3010][3010] = {0};
int main()
{
    int n,l,f,v[3010],w[3010];
    scanf("%d%d%d",&n,&l,&f);
    for(int i = 0; i < n; i++)scanf("%d%d",&v[i],&w[i]);
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= l; j++)
        {
            if(i == 0 || j == 0);
            else
            {
                dp[i][j] = max(dp[i - 1][j],dp[i][j - 1]);
                if(w[i - 1] <= j && !(j - w[i - 1] < f && f < j))
                    dp[i][j] = max(dp[i][j],dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
        }
    /*for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= l; j++)
        {
            printf("%3d",dp[i][j]);
        }
        printf("\n");
    }*/
    printf("%d\n",dp[n][l]);
    return 0;
}

Measured memory_bytes: 37980
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define mp make_pair
#define MOD (ll)(1e9+7)

char s[101010];
ll dp[101010][2];
ll i, j, k,o;

int main(){
    scanf("%s",s);
    for (i = 1; s[i];i++){
        if(s[i]==s[i-1]){
            break;
        }
    }
    if(s[i]=='\0'){
        printf("1");
        return 0;
    }
    
    for (i = 0; s[i];i++){
        ll ab = (s[i] - 'a');
        dp[i + 1][ab] = (dp[i][ab] + dp[i][!ab]) % MOD;
        dp[i + 1][!ab] = (dp[i][ab]) % MOD;
        if(o==0){
            dp[i + 1][ab]++;
            dp[i + 1][ab] %= MOD;
        }
        o = (o + ab + 1) % 3;
    }
    printf("%lld", (dp[i][0]+dp[i][1])%MOD);
    return 0;
}

Measured memory_bytes: 1920
a, b, c, x, y = map(int, input().split())
tot = min(a*x + b*y, 2*c*max(x,y))
if x > y:
    tot = min(tot, a*(x-y)+2*c*min(x,y))
elif x < y:
    tot = min(tot, b*(y-x)+2*c*min(x,y))
print(tot)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int w=0,n=0,e=0,s=0,i;
    cin>>a;
    for(i=0;i<a.length();i++){
    if(a[i]=='W'){
	w=1;
	}
    if(a[i]=='N'){
	n=1;
	}
    if(a[i]=='E'){
	e=1;
	}
    if(a[i]=='S'){
	s=1;
	}}
    if((w==0 && e==0 && n==1 && s==1) || (w==0 && e==0 && n==0 && s==0) || (w==1 && e==1 && n==0 && s==0) || (w==1 && e==1 && n==1 && s==1)){
	cout<<"Yes"<<endl;
	}
	else{
	cout<<"No"<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)
// コンパイル　g++ -std=c++17 a.cpp

int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec.at(i);
    }

    ll flag = 0;
    rep(i,n){
        if(vec.at(i) % 2 == 0){
            if(vec.at(i) % 3 == 0 || vec.at(i) % 5 == 0){
                continue;
            }else{
                flag = 1;
            }
        }
    }

    if(flag == 0){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }



}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[200005];
int b[200005];
int main(void)
{
    int n;
    cin >> n;
    for(int i=1;i<n;i++)
    {
        cin >> a[i];
        b[a[i]]++;
    }
    for(int i=1;i<=n;i++)
        cout << b[i] << endl;
    return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N;cin>>N;
  int x=N*800;
  int y=(N/15)*200;

  cout<<x-y<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; }
	rep(i, 1, N)v[i] += v[i - 1];
	int ans(INF);
	rep(i, 0, -1 + N) {
		chmin(ans, abs(v[i] - (v.back() - v[i])));

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(auto &x: a) cin >> x;
  a.push_back(0);
  sort(a.begin(), a.end());
  int l = 0;
  int r = a.size();
  while(r - l > 1) {
    int pivot = (r + l) / 2;
    if(a[pivot] >= k) {
      r = pivot;
      continue;
    }
    vector<int> dp(k);
    dp[0] = 1;
    REP(i, a.size()) {
      if(i == pivot) continue;
      int x = a[i];
      for(int j = k - 1; j >= x; --j) {
        dp[j] = max(dp[j], dp[j-x]);
      }
    }
    bool flag = false;
    for(int i = k - a[pivot]; i<k; ++i) {
      if(dp[i]) {
        flag = true;
        break;
      }
    }
    if(flag) r = pivot;
    else l = pivot;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <bitset>
using namespace std;

int upb(int n)
{
  int ret=0;
  while(n>0) ret++, n/=2;
  return ret;
}

int main()
{
  //vector<bool> close(1<<(5*5), false);
  bitset<1<<(5*5)> close;

  for (int n; cin>>n, !(n==0); ){

    vector<vector<int> > pats(n*n+1);
    vector<vector<int> > tmp(n, vector<int>(n, 0));
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	for (int k=i; k<n; k++){
	  for (int l=j; l<n; l++){
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=1;
	    int bd=0;
	    for (int a=0; a<n; a++){
	      for (int b=0; b<n; b++){
		bd=(bd<<1)|tmp[a][b];
	      }
	    }
	    pats[upb(bd)].push_back(bd);
	    for (int a=i; a<=k; a++)
	      for (int b=j; b<=l; b++)
		tmp[a][b]=0;
	  }
	}
      }
    }

    int bd=0;
    for (int i=0; i<n; i++){
      for (int j=0; j<n; j++){
	int t; cin>>t;
	bd=(bd<<1)|t;
      }
    }

    close.reset();
    /*
    for (int i=0; i<(n*n); i++)
      close[i]=false;
    */

    queue<pair<int, int> > mm;
    mm.push(make_pair(0, bd));
    close[bd]=true;
    while(!mm.empty()){
      int dep=mm.front().first;
      int cbd=mm.front().second;
      mm.pop();
      //cout<<cbd<<endl;
      int ub=upb(cbd);
      for (int i=0; i<pats[ub].size(); i++){
	int nbd=cbd^pats[ub][i];
	if (nbd==0){
	  for (int i=0; i<=dep; i++)
	    cout<<"myon";
	  cout<<endl;
	  goto _exit;
	}
	//cout<<"*** "<<nbd<<endl;
	if (close[nbd]) continue;
	close[nbd]=true;
	mm.push(make_pair(dep+1, nbd));
      }
    }
  _exit:;
  }
  return 0;
}

Measured memory_bytes: 5840
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll n,flag=-1,ans=0;
    cin >> n;
    ll a[n],b[n],c[n];
    for (ll i=0;i<n;i++)cin >> a[i];
    for (ll i=0;i<n;i++)cin >> b[i];
    for (ll i=0;i<n-1;i++)cin >> c[i];
    for (ll i=0;i<n;i++){
        if (flag+1==a[i]){
            ans+=c[a[i]-2];
            ans+=b[a[i]-1];
            flag=a[i];
            continue;
        }
        ans+=b[a[i]-1];
        flag=a[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int x, a, b;
  	cin >> x >> a >> b;
    if(b <= a)  cout << "delicious" << endl;
    else if(a < b && b <= a + x) cout << "safe" << endl;
    else if(b > a + x) cout << "dangerous" << endl;
}

Measured memory_bytes: 256
import math

N, K = map(int, input().split())
K = min(41, K)
A = list(map(int, input().split()))
A.insert(0, 0)

def operation():
  global A, N
  B = [0] * (N+1)
  for i in range(1, N+1):
    left = max(1, math.ceil(i - A[i] - 0.5))
    right = min(N, math.floor(i + A[i] + 0.5))
    B[left] += 1
    if right+1 <= N:
      B[right+1] -= 1
  for i in range(1, N+1):
    B[i] += B[i-1]
  return B


operation()

#print(A)
#print(B)

for _ in range(K):
  A = operation()

print(*A[1:])



Measured memory_bytes: 155540