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

int main(){
    int H, W;
    
    while(true){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return b.second > a.second;
    }
    return a.first < b.first;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);
    map<char, string> mp2;
    mp2['A'] = "00000";
    mp2['B'] = "00001";
    mp2['C'] = "00010";
    mp2['D'] = "00011";
    mp2['E'] = "00100";
    mp2['F'] = "00101";
    mp2['G'] = "00110";
    mp2['H'] = "00111";

    mp2['I'] = "01000";
    mp2['J'] = "01001";
    mp2['K'] = "01010";
    mp2['L'] = "01011";
    mp2['M'] = "01100";
    mp2['N'] = "01101";
    mp2['O'] = "01110";
    mp2['P'] = "01111";

    mp2['Q'] = "10000";
    mp2['R'] = "10001";
    mp2['S'] = "10010";
    mp2['T'] = "10011";
    mp2['U'] = "10100";
    mp2['V'] = "10101";
    mp2['W'] = "10110";
    mp2['X'] = "10111";

    mp2['Y'] = "11000";
    mp2['Z'] = "11001";
    mp2[' '] = "11010";
    mp2['.'] = "11011";
    mp2[','] = "11100";
    mp2['-'] = "11101";
    mp2['\''] = "11110";
    mp2['?'] = "11111";

    map<string, char> mp1;
    mp1["101"] = ' ';
    mp1["000000"] = '\'';
    mp1["000011"] = ',';
    mp1["10010001"] = '-';
    mp1["010001"] = '.';
    mp1["000001"] = '?';
    mp1["100101"] = 'A';
    mp1["10011010"] = 'B';
    mp1["0101"] = 'C';
    mp1["0001"] = 'D';
    mp1["110"] = 'E';
    mp1["01001"] = 'F';
    mp1["10011011"] = 'G';
    mp1["010000"] = 'H';
    mp1["0111"] = 'I';
    mp1["10011000"] = 'J';
    mp1["0110"] = 'K';
    mp1["00100"] = 'L';
    mp1["10011001"] = 'M';
    mp1["10011110"] = 'N';
    mp1["00101"] = 'O';
    mp1["111"] = 'P';
    mp1["10011111"] = 'Q';
    mp1["1000"] = 'R';
    mp1["00110"] = 'S';
    mp1["00111"] = 'T';
    mp1["10011100"] = 'U';
    mp1["10011101"] = 'V';
    mp1["000010"] = 'W';
    mp1["10010010"] = 'X';
    mp1["10010011"] = 'Y';
    mp1["10010000"] = 'Z';
    string s;
    while (getline(cin, s))
    {
        string code = "";
        int n = s.size();
        for (int i = 0; i < n; ++i)
        {
            code += mp2[s[i]];
        }
        //cout << code << endl;

        int m = code.size();
        string ans = "";

        for (int i = 0; i < m; ++i)
        {
            ans += code[i];
            if (mp1.find(ans) != mp1.end())
            {
                cout << mp1[ans];
                ans = "";
            }
        }
        cout << endl;
    }
    return 0;
}


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

const int MOD = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	long long ans = 1;
	for (int i = 1; i <= N; ++i) {
		ans = (ans * i) % MOD;
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(NULL);
    
    int h,w,i,j;
    cin >> h >> w;
     long int dp[h][w];char arr[h][w];
    
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin >> arr[i][j];
        }
    }
    dp[0][0]=1;
    for(i=1;i<w;i++){
        if(arr[0][i] == '#')
        dp[0][i]=0;
        else
        dp[0][i]=dp[0][i-1];
    }
    for(i=1;i<h;i++){
        if(arr[i][0] == '#')
        dp[i][0]=0;
        else
        dp[i][0]=dp[i-1][0];
    }
    
    for(i=1;i<h;i++){
        for(j=1;j<w;j++){
            if(arr[i][j] == '#')
            dp[i][j]=0;
            else
            dp[i][j]= (dp[i-1][j] + dp[i][j-1])%1000000007;
        }
    }
    cout << dp[h-1][w-1];
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;// > (10^5 - 1) * 10^4

struct edge{
    int to;
    int weight;
};

int main(){
    int n, m;// number of nodes & edges
    cin >> n >> m;

    vector<vector<edge>> graph(n);
    for (int i=0; i<m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l -= 1;
        r -= 1;
        graph[l].push_back(edge({r, d}));
        graph[r].push_back(edge({l, -d}));
    }

    vector<int> x(n, INF);
    for(int i=0; i<n; i++){
        if(x[i] != INF) continue;
        else{
            queue<int> q;
            x[i] = 0;
            q.push(i);
            while(!q.empty()){
                int current = q.front();
                q.pop();
                //cout << current << endl;

                for(edge adjacent : graph[current]){
                    if(x[adjacent.to] != INF){
                        // check
                        if(x[adjacent.to] != x[current] + adjacent.weight){
                            cout << "No" << endl;
                            return 0;
                        }
                    }
                    else{
                        q.push(adjacent.to);
                        x[adjacent.to] = x[current] + adjacent.weight;
                    }
                }
            }
        }   
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
int main(){
  char b;
  cin >> b;
  switch(b){
    case 'A':
      cout << 'T' << endl;
      break;
    case 'C':
      cout << 'G' << endl;
      break;
    case 'T':
      cout << 'A' << endl;
      break;
    case 'G':
      cout << 'C' << endl;
      break;
    }

  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
const int MAX = 510000;
const int MOD = 1000000007;
int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  
  ll tmp = a*c;
  //cout << a*c << endl;
  if(tmp < a*d){
    tmp = a*d;
  }
  if(tmp < b*c){
    tmp = b*c;
  }
  
  if(tmp < b*d){
    tmp = b*d;
  }
  
  cout << tmp;
}


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

#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

int main() {
  char c;
  cin >> c;

  if (c >= 'A' && c <= 'Z')
    cout << "A" << endl;
  else
    cout << "a" << endl;

  return 0;
}


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


int main(){

    float n;

    cin >> n;

    // float guusu = n/2;
    int evennum = (n+1) / 2;

    // cout << "n= " << n << endl;
    // cout << evennum << endl;


    cout << static_cast<float>(evennum) / n << endl;

    return 0;
}

Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef gp_hash_table < int, int > fast;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test();

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << "\n";
    } else {
        cout << "red\n";
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, d, a, b;
  cin >> n >> d;
  int ct = 0;
  while (n--) {
    cin >> a >> b;
    if ((a * a + b * b) <= (d * d))
      ct++;
  }
  cout << ct << endl;
}

Measured memory_bytes: 3652
macro_rules! parse_line {
    [$( $x:tt : $t:ty ),+] => {
        //declare variables
        $( let $x: $t; )+
        {
            use std::str::FromStr;
            // read
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            #[allow(deprecated)]
            let mut splits = buf.trim_right().split_whitespace();
            // assign each variable
            $(
                $x = splits.next().and_then(|s| <$t>::from_str(s).ok()).unwrap();
            )+
            // all strs should be used for assignment
            assert!(splits.next().is_none());
        }
    };
}

#[derive(Debug, Clone, Copy)]
struct Query {
    a: usize,
    b: usize,
    c: usize,
    d: usize,
}

fn main() {
    parse_line![n: usize, m: usize, q: usize];

    let queries = {
        let mut temp = vec![];
        for _ in 0..q {
            parse_line![a: usize, b: usize, c: usize, d: usize];
            temp.push(Query {
                a: a,
                b: b,
                c: c,
                d: d,
            });
        }
        temp
    };

    let mut max_score = 0;
    let mut nums = vec![1; n];

    loop {
        let score = queries
            .iter()
            .filter(|&&Query { a, b, c, .. }| nums[b - 1] - nums[a - 1] == c)
            .map(|&Query { d, .. }| d)
            .sum::<usize>();

        max_score = std::cmp::max(max_score, score);

        if next_nums(&mut nums, m).is_none() {
            break;
        }
    }

    println!("{} ", max_score);
}

fn next_nums(nums: &mut [usize], m: usize) -> Option<()> {
    let len = nums.len();
    // この位の値をカウントアップ
    nums[len - 1] += 1;
    if nums[len - 1] > m {
        // これ以上位上げができなければ終了
        if len - 1 == 0 {
            None
        } else {
            // 次の位をカウントアップ
            next_nums(&mut nums[..len - 1], m)?;
            // この数列は単調非減少だから
            // この位の値が次の位の値と同じになるようにする
            nums[len - 1] = nums[len - 2];
            Some(())
        }
    } else {
        Some(())
    }
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	if(c=='-')f=-1,c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n;
int main(){
	n=d;
	if(n>=400&&n<=599)cout<<8;
	if(n>=600&&n<=799)cout<<7;
	if(n>=800&&n<=999)cout<<6;
	if(n>=1000&&n<=1199)cout<<5;
	if(n>=1200&&n<=1399)cout<<4;
	if(n>=1400&&n<=1599)cout<<3;
	if(n>=1600&&n<=1799)cout<<2;
	if(n>=1800&&n<=1999)cout<<1;
	return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#define pb push_back 
#include<vector>
#include<queue>
#include<functional>
#include<utility>
#define all(c) c.begin(), c.end()
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

struct State {
  int v, l, dist;
  bool operator<(const State& o) const {
    return dist > o.dist;
  }
};
 const int INF = 100000000;
int main(){
  int n,m,l;
  while(cin >>n>>m>>l,n||m) {
    VVI cost(n, VI(n, INF));
    VVI foes(n, VI(n, INF));
    rep(i,m) {
      int a,b,d,e;
      cin >>a>>b>>d>>e;
      a--; b--;
      foes[a][b] = foes[b][a] = e;
      cost[a][b] = cost[b][a] = d;
    }
   
    VVI dist(l+1, VI(n, INF));
    dist[l][0] = 0;
    priority_queue<State, vector<State> > que;
    que.push((State){0,l,0});
    while(!que.empty()) {
      State s = que.top();
      que.pop();
      if (dist[s.l][s.v] < s.dist) continue;
      //      cout << s.l << " "<<s.v << " "<<s.dist << endl;
      for(int i = 0; i < n; i++) {
	if (s.l >= cost[i][s.v]) {
	  int nl = s.l - cost[i][s.v];
	  if (dist[nl][i] > s.dist) {
	    dist[nl][i] = s.dist;
	    que.push((State){i,nl,s.dist});
	  }
	}
	if (dist[s.l][i] > s.dist + foes[i][s.v]) {
	  dist[s.l][i] = s.dist + foes[i][s.v];
	  que.push((State){i,s.l,dist[s.l][i]});
	}	
      }
    }
    int minFoes = INF;
    rep(i,l+1) minFoes = min(minFoes, dist[i][n-1]);
    cout << minFoes << endl;
   
  }
  return 0;
}

Measured memory_bytes: 1668
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n,k,s;
    cin>>n>>k;
    int * a=new int[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    s=0;
    for(int i=n-1;i>=n-k;i--)
        s+=a[i];
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
import math

N, D = map(int, input().split(" "))

XX = [list(map(int, input().split(" "))) for i in range(N)]

res = 0
x = 0
while x <= len(XX) - 2:
    y = x + 1
    while y <= len(XX) - 1:
        sum = 0
        for i in range(D):
            sum += math.pow(XX[x][i] - XX[y][i], 2)
        h = int(math.sqrt(sum))
        if math.pow(int(math.sqrt(sum)), 2) == sum:
            res += 1
        y += 1
    x += 1

print(res)


Measured memory_bytes: 3188
(defun func (&rest args)
  (loop for i on args
        sum
        (loop for j in i
              sum (* (car i) j))))

(defun main (n
             &aux
               (ans (make-array (1+ n) :initial-element 0)))
  (labels ((check (&rest args)
             (<= (apply #'func args) n)))
    (loop for i from 1
          while (check i)
          do
             (loop for j from 1
                   while (check i j)
                   do
                      (loop for k from 1
                            while (check i j k)
                            do
                               (incf (aref ans (func i j k))))))
    (cdr (coerce ans 'list))))

(format t "~{~a~%~}"
        (main (read)))


Measured memory_bytes: 60856
/*
Hanit Banga
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 1e5 + 5;

ll a[N];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	ll temp = 0, sum = a[0];
	if (a[0] <= 0)
	{
		temp = 1 - a[0];
		sum = 1;
	}

	for (int i = 1; i < n; ++i)
	{
		if (sum < 0)
		{
			if (a[i] < 1 - sum)
			{
				temp += 1 - sum - a[i];
				sum = 1;
			}

			else
				sum += a[i];
		}

		else if (a[i] > -(sum + 1))
		{
			temp += a[i] + sum + 1;
			sum = -1;
		}

		else
			sum += a[i];
	}

	ll ans = temp;
	temp = 0, sum = a[0];
	if (a[0] >= 0)
	{
		temp = a[0] + 1;
		sum = -1;
	}

	for (int i = 1; i < n; ++i)
	{
		if (sum < 0)
		{
			if (a[i] < 1 - sum)
			{
				temp += 1 - sum - a[i];
				sum = 1;
			}

			else
				sum += a[i];
		}

		else if (a[i] > -(sum + 1))
		{
			temp += a[i] + sum + 1;
			sum = -1;
		}

		else
			sum += a[i];
	}

	ans = min(ans, temp);
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n, j;
    cin >> n;
    int d[n];
    rep(i,n) cin >> d[i];
    int ans = 0;
    rep(i,n){
        for(j=i+1; j<n; j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;


ll cnt2(ll n) {
  return 0;
}

ll comb(ll n, ll r) {
  for (ll base = 60; base >= 1; base--) {
    if (r > n) return 0;
    if (n >= (1LL << base)) n %= (1LL << base);
    if (r >= (1LL << base)) r %= (1LL << base);
  }

  if (n == 0 && r == 1) {
    return 0;
  } else {
    return 1;
  }
}


int main() {
  ll N;
  string A;
  
  cin >> N >> A;

  vector<ll> a;

  char current = A[0];


  // for (int i = 0; i < 30; i++) {
  //   for (int r = 0; r <= i; r++) {
  //     cout << comb(i, r) << " ";
  //   }
  //   cout << endl;
  // }

  for (ll i = 1; i < N; i++) {
    a.push_back(abs(A[i] - current));
    current = A[i];
  }


  // 0 or 2
  bool is_zero_or_two = true;
  for (ll c : a) {
    if (c == 1) {
      is_zero_or_two = false;
    }
  }

  // 0 or 2
  ll mult = 1;
  if (is_zero_or_two) {
    mult = 2;
    for (int i = 0; i < N - 1; i++) {
      a[i] /= 2;
    }
  }

  ll res = 0;

  for (int i = 0; i < N - 1; i++) {
    ll com = comb(N - 2, i);
    res = (res + com * a[i]) % 2;
  }

  cout << res * mult << endl;

  return 0;
}


Measured memory_bytes: 12268
from math import gcd
A, B, C, D = map(int, input().split())
lcm = C * D // gcd(C, D)
b = B//C + B//D - B//lcm
a = (A-1)//C + (A-1)//D - (A-1)//lcm
print(B-A+1-b+a)

Measured memory_bytes: 9112
// abydbc639iixt3v6powmr2xrjj11dhey
#include<iostream>
#include<vector>
#include<cstring>
#include<unordered_map>
#include<math.h>
#include<map>
#include<algorithm>
#include<iomanip>
#define vi vector<int>
#define ll long long
using namespace std;

long long int mod(string n, long long int k){
    long long int res = 0; 
    for (long long int i = 0; i < n.length(); i++) 
         res = (res*10 + (int)n[i] - '0') %k;
    return res;
}
string longDivision(string number, long long int divisor) 
{
    // As result can be very large store it in string 
    string ans; 
    
    // Find prefix of number that is larger 
    // than divisor. 
    long long int idx = 0; 
    long long int temp = number[idx] - '0'; 
    while (temp < divisor) 
       temp = temp * 10 + (number[++idx] - '0'); 
    
    // Repeatedly divide divisor with temp. After  
    // every division, update temp to include one  
    // more digit. 
    while (number.size() > idx) 
    { 
        // Store result in answer i.e. temp / divisor 
        ans += (temp / divisor) + '0'; 
          
        // Take next digit of number 
        temp = (temp % divisor) * 10 + number[++idx] - '0'; 
    } 
      
    // If divisor is greater than number 
    if (ans.length() == 0) 
        return "0"; 
      
    // else return ans 
    return ans; 
}



int n,k,Min=1e9;
vector<int> a;
vector<int> dp(1e5+2,-1);
bool f(int sum){
    if(sum<Min) return false;
    if(dp[sum]!=-1) return (bool)dp[sum];
    
    for(int i=0;i<n;i++){
        if(sum>=a[i])
            {if(f(sum-a[i])==false) {dp[sum]=1; return true;}}
        else break;
    }
    dp[sum]=0;
    return false;
}

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

    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a.push_back(x);
        Min=min(Min, x);
    }
    sort(a.begin(),a.end());
    if(f(k)) cout<<"First\n";
    else cout<<"Second\n";

    return 0;

}
//1 2 4 5 3
//
// 1 1 2 3 4
/*
    11
    10
    01

->
    101 
    011
    010
    001

a1:
    111
    110
    111
    100 ->X=1

    010
    100
    101
    110



*/


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,m,a[100005],b[100005],x,y;
vector<long long>p[100005];
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>a[i]>>b[i];
		p[a[i]].push_back(b[i]);
	}
	for(int i=1;i<=n;i++)
	  sort(p[i].begin(),p[i].end());
	for(int i=0;i<m;i++)
	{
		int pos=lower_bound(p[a[i]].begin(),p[a[i]].end(),b[i])-p[a[i]].begin()+1;
		x=a[i];
		y=0;
		while(x>0) x/=10,y++;
		x=6-y;
		for(int j=1;j<=x;j++) cout<<0;
		cout<<a[i];
		x=pos;
		y=0;
		while(x>0) x/=10,y++;
		x=6-y;
		for(int i=1;i<=x;i++) cout<<0;
		cout<<pos<<endl;
	}
	return 0;
}

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

int main() {
	int N;	// ひなあられの個数.
	cin >> N;

	string answer = "Three";
	for (int i = 0; i < N; i++) {
		string S;	// ひなあられの色.
		cin >> S;
		if (S == "Y") {
			answer = "Four";
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<bool>vec(N,true);
  vector<int>F(N);
  int WA=0,AC=0;
  for(int i=0; i<M; i++){
    int p;
    string S;
    cin >> p >> S;
    if(vec[p-1] && S == "WA"){
      WA++;
      F[p-1]++;
    }
    if(vec[p-1] && S == "AC"){
      AC++;
      vec[p-1]=false;
    }
  }
  for(int i=0; i<N; i++){
    if(vec[i]){
      WA -= F[i];
    }
  }
  cout << AC << " " << WA << endl;
}


Measured memory_bytes: 3764
n = int(input())
a = list(map(int, input().split()))
print(*a)

for i in range(1, n):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j = j - 1
    a[j+1] = v
    print(*a)


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<char> S(N);
  for(int i = 0; i < N; i++) cin >> S[i];
  int cnt = 0;
  for(int i = N - 1; i > 0; i--){
    if(S[i] == 'E') cnt++;
  }
  int ans = cnt;
  int idx = 1;
  while(idx < N){
    if(S[idx - 1] == 'E' && S[idx] == 'E') cnt--;
    else if(S[idx - 1] == 'W' && S[idx] == 'W') cnt++;
    else if(S[idx - 1] == 'E' && S[idx] == 'W') ;
    else if(S[idx - 1] == 'W' && S[idx] == 'E') ;
    ans = min(ans,cnt);
    idx++;
  }
  cout << ans;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int cnt = 0;
		for(int i = 1; i <= a; i++){
			if(i < 10 || (100 <= i && i < 1000) || (10000 <= i && i < 100000)){
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main ()
{
    int N;
    cin >> N;
    int total = 0;
	map<int,bool> m;
    for ( int i =0; i < N ; i ++){
        int a;
        cin >>  a;

		if(m.find(a) == m.end()){
			m[a] = true;
            total++;
		} else {
			if(m[a]) {
                total--;
			} else {
                total++;
            }
			m[a] = !m[a];
		}
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
ll n,m,k;
int a[105];
int main()
{
    while(~scanf("%lld",&n))
    {
        for(ll i=0;i<n;i++)
            scanf("%d",&a[i]);
        int minn=99999999;
        int ans;
        for(int i=-100;i<101;i++)
        {
            ans=0;
            for(int j=0;j<n;j++)
            {
                ans+=(i-a[j])*(i-a[j]);
            }
            minn=min(minn,ans);
        }
        cout<<minn<<endl;
    }
    return 0;
}


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

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

int main() {
	int N;
	cin >> N;
	int a[10010];

	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}

	sort(a, a + N);
	int sum = 0;
	for (int i = 0; i < N-1; i++)
	{
		sum += a[i];
	}

	sum += a[N - 1] / 2;

	cout << sum << endl;
	return 0;
}


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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

int main(void) {
	ll l,tmp;
	cin >> l;
	deque<int> c;
	for (int i = 0; i < l; i++) {
		cin >> tmp;
		for (int j = 0; j < c.size(); j++) {
			if (c[j] == tmp) {
				cout << i + 1 << "\n";
				return 0;
			}
		}
		if (tmp > 0) {
			c.push_back(tmp);
		}else{
			if (i == 0) {
				cout << "1" << "\n";
				return 0;
			}
			else if (c.back() == -1 * tmp) c.pop_back();
			else {
				cout << i + 1 << "\n";
				return 0;
			}
		}
	}
	cout << "OK" << "\n";
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <cstdio>
#include <chrono>
#include <random>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, -1, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265
const long long int MAXN = 3e3+10;
const long long int MINN = 1e5+10;
const long long int inf = 1e18+7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi; 
typedef stack<int> st;

ll n,a[MAXN],dp[MAXN][MAXN],s;

ll foo(int l, int r){
	if(l+1==r){
		dp[l][r]=max(a[l],a[r]);
		return dp[l][r];
	}
	if(l==r){
		dp[l][r]=a[l];
		return dp[l][r];
	}
	ll x,y,z;
	x=(dp[l+1][r-1]==-1?foo(l+1,r-1):dp[l+1][r-1]);
	y=(dp[l+2][r]==-1?foo(l+2,r):dp[l+2][r]);
	z=(dp[l][r-2]==-1?foo(l,r-2):dp[l][r-2]);
	dp[l][r]=max(a[l]+min(x,y),a[r]+min(x,z));
	return dp[l][r];
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    DRACARYS    
    cin>>n;
    fill(dp);
    repA(i,1,n) cin>>a[i],s+=a[i];
    cout<<2*foo(1,n)-s<<endl;
    return 0;
}



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

int main(){

  string S;
  int numA=-1, numZ, ans=0;
  getline(cin, S);

  for(int i=0; i<S.size(); i++){
    if(S[i]=='A' && numA < 0) numA = i;
    if(S[i]=='Z') numZ = i;
  }

  ans = numZ - numA + 1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[8]={0,1,0,-1,1,1,-1,-1},dy[8]={1,0,-1,0,1,-1,1,-1};

int h,w;
vvi a;

int main(){
	cin>>h>>w;
	a=vvi(h,vi(w));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		char c;
		cin>>c;
		if(c=='#'){
			for(int k=0;k<8;k++){
				int x=i+dx[k],y=j+dy[k];
				if(x>=0&&x<h&&y>=0&&y<w) a[x][y]++;
			}
			a[i][j]=-inf;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]>=0) cout<<a[i][j];
			else cout<<'#';
		}
		cout<<endl;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
int main(){
    ll N , count = 0;
    cin >> N;
    vector <ll> A(N);
    ll tallest = A[0];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        if(tallest > A[i]){
            count += (tallest - A[i]);
            A[i] = tallest;
        }
        else{
            tallest = A[i];
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 4824
def a():
    N = int(input())
    L = list(map(int,input().split()))
    ans = 0

    if(N<3):
        print(ans)
        return 0
    for x in range(N):
        for y in range(x+1,N):
            for z in range(y+1,N):
                if(L[x]!=L[y] and L[y]!=L[z] and L[z]!=L[x]):
                    if(L[x]+L[y]>L[z] and L[y]+L[z]>L[x] and L[z]+L[x]>L[y]):
                        ans+=1
    print(ans)

a()


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


int main(){
    long long N, K;
    cin >> N >> K;
    N = N % K - K;
    long long plus = N + K;
    N *= (-1);
    cout << min(N, plus) << endl;

    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int b[n];
    for (int i = 0; i < n - 1; i++){
        cin >> b[i];
    }

    int ans = b[0];
    for (int i = 0; i < n - 2; i++){
        ans += min(b[i], b[i + 1]);
    }
    ans += b[n - 2];
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm> // for sorting 
#include <iostream> 
typedef long long int lli;
using namespace std; 
#define MOD 1000000007
lli A[1000000];
lli n,k;
lli maxProductSubarrayOfSizeK(lli A[], lli n, lli k) 
{ 
    sort(A, A + n); 
    lli product = 1; 
    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--){ 
            product *= A[i]%MOD; 
            product %=MOD;
        }
        return (product+MOD)%MOD; 
    } 
    int i = 0; 
    int j = n - 1; 
    if (k & 1) { 
        product *= A[j]%MOD; 
        product %= MOD;
        j--; 
        k--; 
    } 
    k >>= 1; 
    for (int itr = 0; itr < k; itr++) { 
        lli left_product = A[i] * A[i + 1]; 
        lli right_product = A[j] * A[j - 1]; 
        if (left_product > right_product) { 
            product *= left_product%MOD; 
            product %=MOD;
            i += 2; 
        } 
        else { 
            product *= right_product%MOD; 
            product %=MOD;
            j -= 2; 
        } 
    } 
    return (product+MOD)%MOD; 
} 
/*void brute(){
    for(int i = 0; i<n; i++){
        for(int j = i+1; j<n; j++){
            for(int k = j+1; k<n; k++){
                if(arr[i]*arr[j]* arr[k]> max){

                }
            }
        }
    }
}*/
int main() 
{ 
    cin>>n>>k;
    for(int i = 0; i<n; i++){
        cin>>A[i];
    }
    cout << maxProductSubarrayOfSizeK(A, n, k)<<endl;  
} 

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

int main() {
    int r,g,b;
    /*char R,G,B;
    scanf("%c %c %c",&R,&G,&B);*/
    int s=0;
    while( scanf("%d%d%d",&r,&g,&b)!=EOF) {
        s=r*100+g*10+b;
        if(s%4==0)
            printf("YES\n");
        else
            printf("NO\n");
    }
return 0;
}

Measured memory_bytes: 128
N = int(input())
sum_a = []
a = [int(i) for i in input().split()]
tmp = 0
for i in a:
    tmp += i
    sum_a.append(tmp)

for i in range(N-1):
    if i == 0:
        ans = abs(sum_a[i] - (tmp - sum_a[i]))
    else:
        ans = min(ans, abs(sum_a[i] - (tmp - sum_a[i])))

print(ans)


Measured memory_bytes: 24832
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=list(input())
    S.sort()
    S=''.join(S)
    YesNo(S=='abc')
    

if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  int count=0, ans=0;
  
  for (int i; i<n; i++) {
    cin >> h.at(i);
  }
  
  for (int i; i<n-1; i++) {
    if (h.at(i+1)-h.at(i)<=0) {
      count++;
      ans=max(count,ans);
    }
    else {
      ans=max(count,ans);
      count=0;
    }
  }
  
   
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define INF INT_MAX

void solve()
{
    ll n,i;
    cin>>n;
    vector<vector<ll>> v(n,vector<ll>(3));
    vector<vector<ll>> dp(n,vector<ll>(3));

    for(i=0;i<n;i++)
    {
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }

    dp[0][0]=v[0][0];
    dp[0][1]=v[0][1];
    dp[0][2]=v[0][2];

    for(i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+v[i][2];
    }

    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

int main()
{
    solve();
}


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

int main(){
    ll a,b,x,ans;cin>>a>>b>>x;

    if(a!=0) cout<<b/x-(a-1)/x<<endl;
    else{cout<<b/x+1<<endl;}
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 string s;
  cin >> s;
  rep(i,0,s.length()) s[i]='x';
  cout << s << endl;
  
}


Measured memory_bytes: 256
n, m = map(int, raw_input().split())

f = dict()
for i in range(m):
    a, b = map(int, raw_input().split())
    if a in f:
        f[a].append(b)
    else:
        f[a] = [b]
if m < 2:
    print("IMPOSSIBLE")
    exit()

for k, v in f.iteritems():
    if k == 1:
        for vv in v:
            if vv not in f:
                continue
            if n in f[vv]:
                print("POSSIBLE")
                exit()
print("IMPOSSIBLE")

Measured memory_bytes: 35128
N = int(input())
X = list(map(int,input().split()))
X_sort = sorted(X)

medi1 = X_sort[int(N/2) - 1]
medi2 = X_sort[int(N/2)]

for i in range(N):
    if X[i] >= medi2:
        print(medi1)
    else:
        print(medi2)

Measured memory_bytes: 25624
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

constexpr int MaxN = 100 + 10;
int n;
int S[MaxN];
bool candidate[MaxN * MaxN];
bool done[MaxN][MaxN * MaxN];

void Solve(int no, int sum) {
    if (done[no][sum]) {
        return;
    }

    done[no][sum] = true;
    candidate[sum] = true;

    if (no >= n) {
        return;
    }
    
    Solve(no + 1, sum);
    Solve(no + 1, sum + S[no]);
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }

    Solve(0, 0);

    int ans = 0;
    for (int i = 0; i < MaxN * MaxN; i++) {
        if (i % 10 != 0 && candidate[i]) {
            ans = i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1152
#!/usr/bin/env python3

def main():
    N = int(input())
    na = list(map(int, input().split()))
    D, X = na[0], na[1]
    A = []
    for i in range(N):
        A.append(int(input()))

    r = X
    for i in range(N):
        r += 1 + int((D - 1) / A[i])

    print(r)


if __name__ == '__main__':
    main()



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

int main(){
  int n;
  cin >> n;
  int x[n];
  rep(i,n) cin >> x[i];
  int ans = INF;
  rep(p,101) {
    int k = 0;
    rep(i,n) k += (p-x[i])*(p-x[i]);
    ans = min(ans,k);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.length();
  ll ans = 0;
  for(int bit = 0; bit < (1 << n - 1); bit++){
    string num = "";
    rep(i, n){
      num += s[i];
      if(bit >> i & 1){
        ans += stoll(num);
        num = "";
      }
    }
    if(num != "") ans += stoll(num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            sum = 500*i + 100*j + 50*k
            if x == sum:
                count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
 
 
 
 
 
 
 





const int maxn1=55556;
bool pr[maxn1];
int main()
{
     pr[0]=1,pr[1]=1;
     for(int i=2;i<maxn1;i++){
          if(!pr[i]){
               for(int j=i+i;j<maxn1;j+=i)pr[j]=1;
          }
     }
     int n;
     cin>>n;
     for(int i=31;i<maxn;i+=30){
          if(!pr[i]){
               cout<<i<<" ";
                n--;
          }
         
          if(n==0)break;
     }
    
    

}






















Measured memory_bytes: 3644
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		int first = sc.nextInt();
		int second = sc.nextInt();
		int third = sc.nextInt();
		sc.close();

		System.out.println(first * second > third ? third: first * second);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MOD 1000000007
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
vector<long long int> powt;

int main() {
	array<bool, 4> cou = {};
	char c;
	while (scanf("%c", &c) != EOF) {
		switch (c) {
		case 'S':
			cou[0] = 1;
			break;
		case 'N':
			cou[1] = 1;
			break;
		case 'E':
			cou[2] = 1;
			break;
		case 'W':
			cou[3] = 1;
			break;
		}
	}
	if (cou[0] != cou[1] || cou[2] != cou[3])
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    double ans = 0;
    for(int i=1;i<=n;i++){
        float cnt = 0;
        int tmp = i;
        while (tmp<k){
            tmp *= 2;
            cnt += 1;
        }
        ans += pow(0.5,cnt) /n;
    }
    printf("%.15f\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>							
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;
const ll maxsize = 100000009;



void solve() {
	int n;
	cin >> n; 
	map<int, int> m;
	bool flag = true;
	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		m[x]++;
		if(m[x] > 1) flag = false;
		}
		if(flag) cout << "YES" << endl;
		else cout << "NO" << endl;
}


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


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

int main() {
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    if (A >= K) {
        cout << K << endl;
    }
    else if (A + B >= K) {
        cout << A << endl;
    }
    else {
        cout << A - (K - A - B) << endl;
    }
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

vector<ll> v[maxn], dp(maxn), vis(maxn);

void dfs(ll i){
    vis[i] = 1;

    for(auto u: v[i]){
        if(!vis[u])
            dfs(u);
        dp[i] = max(dp[u]+1, dp[i]);
    }
}

int main(){
    fast;
    
    ll n, m;
    cin>>n>>m;
    
    for(ll i=0;i<m;i++){
        ll x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    
    for(ll i=1;i<=n;i++)
        if(!vis[i])
            dfs(i);
        
    ll ans = 0;
    for(ll i=1;i<=n;i++)
        ans = max(dp[i], ans);
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 47464
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n; cin>>n;
    for(int i=0;i<n;i++){
        cout<<"ACL";
    }
    cout<<endl;
    
}


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    vector<tuple<int, int, int>> query;
    query.emplace_back(0, 0, 0);
    REP(i, N){
        scanInt(ti);
        scanInt(xi);
        scanInt(yi);
        query.emplace_back(ti, xi, yi);
    }
    REP(i, N){
        auto td = get<0>(query[i + 1]) - get<0>(query[i]);
        auto dist = abs(get<1>(query[i + 1]) - get<1>(query[i])) + abs(get<2>(query[i + 1]) - get<2>(query[i]));
        if (!(dist <= td && dist % 2 == td % 2)){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}


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

int main(){
 	vector<int> a(3);
  	int k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	sort(a.begin(),a.end());
  	
  	cout << a[0] + a[1] + (a[2] << k) << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
while (1){
long n,dset[5000],temp=0,max;
cin>>n;
if (n==0)break;
for (int i=0;i<n;i++){
        cin>>dset[i];
}
max=-1000000;
for (int i=0;i<n;i++){
        for (int j=i;j<n;j++){
                temp=temp+dset[j];
                if (max<temp){
                        max=temp;
                }
        }
temp=0;
}
cout<<max<<endl;
}
return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

    if(S[0] == S[1] && S[1] == S[2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(S[1] == S[2] && S[2] == S[3]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S == "SUN") cout << 7 << endl;
  if (S == "MON") cout << 6 << endl;
  if (S == "TUE") cout << 5 << endl;
  if (S == "WED") cout << 4 << endl;
  if (S == "THU") cout << 3 << endl;
  if (S == "FRI") cout << 2 << endl;
  if (S == "SAT") cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;



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

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

    sort(A, A+N);
//    for (int i = 0; i < N; ++i) {
//        cout << A[i] << endl;
//    }
    cout << A[N-1] - A[0] << endl;



    return 0;
}

Measured memory_bytes: 256