akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx")

#include <bits/stdc++.h>

using namespace std;

#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int n, m, k;
vector<vector<int>> a, d;
vector<set<int>> r, c;

void del(int i, int j) {
    auto it = r[i].find(j);
    if (it != r[i].end()) {
        r[i].erase(it);
    }
    it = c[j].find(i);
    if (it != c[j].end()) {
        c[j].erase(it);
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> m >> k;
    a.resize(n, vector<int> (m));
    d.resize(n, vector<int> (m));
    r.resize(n);
    c.resize(m);
    int xs, ys, xe, ye;
    cin >> xs >> ys >> xe >> ye;
    xs--, ys--, xe--, ye--;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            r[i].insert(j);
            c[j].insert(i);
            if (s[j] == '@') {
                a[i][j] = 1;
            } else {
                a[i][j] = 0;
            }
        }
    }

    queue<pair<int, int>> q;
    q.push({xs, ys});
    del(xs, ys);
    while (!q.empty()) {
        auto [x, y] = q.front();
        q.pop();
        while (1) {
            auto it = r[x].lower_bound(y);
            if (it != r[x].end() && (*it) - y <= k) {
                int ny = (*it);
                if (a[x][ny] == 1) break;
                del(x, ny);
                d[x][ny] = d[x][y] + 1;
                q.push({x, ny});
            } else {
                break;
            }
        }
        while (1) {
            auto it = r[x].lower_bound(y);
            if (it != r[x].begin()) {
                --it;
                int ny = (*it);
                if (y - ny <= k) {
                    if (a[x][ny] == 1) break;
                    del(x, ny);
                    d[x][ny] = d[x][y] + 1;
                    q.push({x, ny});
                } else {
                    break;
                }
            } else {
                break;
            }
        }
        while (1) {
            auto it = c[y].lower_bound(x);
            if (it != c[y].end() && (*it) - x <= k) {
                int nx = (*it);
                if (a[nx][y] == 1) break;
                del(nx, y);
                d[nx][y] = d[x][y] + 1;
                q.push({nx, y});
            } else {
                break;
            }
        }
        while (1) {
            auto it = c[y].lower_bound(x);
            if (it != c[y].begin()) {
                --it;
                int nx = (*it);
                if (x - nx <= k) {
                    if (a[nx][y] == 1) break;
                    del(nx, y);
                    d[nx][y] = d[x][y] + 1;
                    q.push({nx, y});
                } else {
                    break;
                }
            } else {
                break;
            }
        }
    }
    if (d[xe][ye] == 0) {
        cout << -1 << '\n';
    } else {
        cout << d[xe][ye] << "\n";
    }


    return 0;
}

Measured memory_bytes: 152744
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a=0;
  for (int i=1; i<=n; i++) {
    for (int j=1; j<=n; j++) {
      for (int k=1; k<=n; k++) {
        int x = gcd(i,j);
        int y = gcd(x,k);
        a += y;
      }
    }
  }
  cout << a << endl; 
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>	
using namespace std;

int main(){
    int H,W,h,w;
    scanf("%d %d",&H,&W);
    scanf("%d %d",&h,&w);
    printf("%d\n",(H-h)*(W-w));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,q;cin>>n>>q;
    int S,T,X;
    vector<tuple<int,int,int>> ban(n);
    rep(i,n){
        cin>>S>>T>>X;
        ban[i]=make_tuple(X,S-X,T-X);
    }
    sort(all(ban));
    vin d(q);
    map<int,int> num;
    set<int> time;
    rep(i,q){
        cin>>d[i];
        num[d[i]]=i;
        time.insert(d[i]);
    }
    time.insert(inf);
    vin ans(q,-1);
    //s<=d<tなるdをxが小さい順に見つけていく
    queue<int> que;
    int x,s,t,m,M,start,end;
    rep(i,n){
        if(time.size()==1)break;
        x=get<0>(ban[i]);
        s=get<1>(ban[i]);
        t=get<2>(ban[i]);
        m=*(time.lower_bound(0));
        M=*(--time.lower_bound(inf));
        if(M<s||t<=m)continue;
        auto l=time.lower_bound(s);
        auto r=time.lower_bound(t);
        for(auto itr=l;itr!=r;itr++){
            ans[num[*itr]]=x;
            que.push(*itr);
        }
        while(que.size()){
            time.erase(que.front());
            que.pop();
        }
    }
    rep(i,q)cout<<ans[i]<<endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include "boost/multiprecision/cpp_int.hpp"
using ll = long long;
using ull = unsigned long long;
namespace mp = boost::multiprecision;

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	int N; std::cin >> N;
	std::map<int, int> map; for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		map[tmp]++;
	}

	int ans = -1;

	for (int X = 0; X <= pow(10, 5); X++) {
		int tmp = map[X - 1] + map[X] + map[X + 1];
		ans = std::max(ans, tmp);
	}

	std::cout << ans;

	return 0;

}

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

int main() {
  string a, b;
  cin >> a >> b;
  
  int k = 0;
  for (int i = 0; i < 3; i++) {
  	if (a[i] == b[i]) k++;
  }
  
  cout << k << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

const ll MOD = 1e9 + 7;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }

ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128

ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}



void __sol(){
    int n,k; cin >> n >> k;
    vector<int> v(n);
    forr(i,n) cin >> v[i];
    sort(all(v));
    ll sum = 0;
    forr(i,k) sum=sum+v[i];
    cout << sum;
}


int main(){
    fastio
    ll tc=1;// cin >> tc;
    while(tc--) __sol();
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
const char* solve() {
    string s;
    cin >> s;
    auto c = s.find('C');
    if (c == string::npos) return "No";
    auto f = s.find('F', c);
    if (f == string::npos) return "No";
    return "Yes";
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
  val cin = Scanner(System.`in`)
  val n = cin.nextInt()

  var maxA = -1
  var minA = 1000000010
  for (i in 0 until n) {
    val a = cin.nextInt()
    maxA = Math.max(maxA, a)
    minA = Math.min(minA, a)
  }

  println(maxA - minA)

  cin.close()
}

Measured memory_bytes: 31264
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	int r, g, b;
	std::cin >> r >> g >> b;
	if ((g*10+b)%4==0)
		std::cout << "YES\n";
	else
		std::cout << "NO\n";
}


Measured memory_bytes: 384
S = list(input())
K = int(input())
characters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n',
              'o','p','q','r','s','t','u','v','w','x','y','z']
L = []
for s in S:
  L.append(characters.index(s))

for i in range(len(L)):
  if L[i] == 0:
    pass
  elif 26-L[i] <= K:
    K -= (26-L[i])
    L[i] = 0
  elif K == 0:
    pass
  else:
    pass

L[len(L)-1] = (L[len(L)-1] + K)%26


P = ""

for l in L:
  P += characters[l]
print(P)

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

int main(){

	int n;
	while (std::cin >> n, n){
		std::vector<int>size(n);

		for (int i = 0; i < n; i++){
			std::cin >> size[i];
		}

		int cnt=0;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n-i-1; j++){
				if (size[j]>size[j + 1]){
					cnt++;
					std::swap(size[j], size[j + 1]);
				}
			}
		}
		std::cout << cnt << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define basic ll n; cin >> n; ll a[n + 1]; for(ll i = 0;i < n;i++) cin >> a[i]
#define f first
#define s second
#define inf 1000000007
#define MAX 10000007
#define T int t; cin >> t; while(t--)
using namespace std;
//vector <ll> a[100005];
ll xyp(ll x,ll y){if(y == 0) return 1LL;if(y == 1) return x;if(y % 2){ll p = xyp(x,y - 1);return (x * p) % mod;}ll p = xyp(x,y / 2);return (p * p) % mod;}
ll inv(ll x){return xyp(x,mod - 2);}
ll fact[MAX];
ll pr[MAX];
vector<ll> rp;
void init(){fact[0] = 1;for(ll i = 1;i < MAX;i++){fact[i] = (fact[i - 1] * i) % mod;}}
ll ncr(ll n,ll r){if(r == 0 || n == r) return 1LL;if(r == 1 || ((n - r) == 1)) return n;ll p = (((fact[n] * inv(fact[r])) % mod) * inv(fact[n - r])) % mod;return p;}
void sieve(){memset(pr,1,sizeof(pr));pr[0] = pr[1] = 0;for(ll i = 2;i < MAX;i++){if(pr[i]){rp.pb(i);for(ll j = i * i;j < MAX;j += i){pr[j] = 0;}}}}
ll a[1005][1005];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	vector<string> v;
	ll n,m;
	cin >> n >> m;
	for(ll i = 0;i < n;i++){
		string s;
		cin >> s;
		v.pb(s);
	}
	for(ll i = 0;i < m;i++){
		if(v[0][i] == '#') break;
		a[0][i] = 1;
	}
	for(ll i = 0;i < n;i++){
		if(v[i][0] == '#') break;
		a[i][0] = 1;
	}
	for(ll i = 1;i < n;i++){
		for(ll j = 1;j < m;j++){
			if(v[i][j] == '#') continue;
			a[i][j] = (a[i][j - 1] + a[i - 1][j]) % mod;
		}
	}
	cout << a[n - 1][m - 1] << "\n";
	return 0;
}

Measured memory_bytes: 9472
#include <iostream>

using namespace std;

int main(void) {
    int N, L;
    cin >> N >> L;
    if(L >= 0) {
        cout << (N-1) * (2*L+N) / 2 << endl;
    } else if(L+N-1 >= 0) {
        cout << N * (2*L+N-1) / 2 << endl;
    } else {
        cout << (N-1) *(2*L+N-2) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
B = iil()
ans = 0
for i in range(1,n-1):
    ans += min(B[i-1],B[i])
print(ans+B[0]+B[-1])

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        char[] s = sc.next().toCharArray();
        int[] white = new int[n+1];
        int[] black = new int[n+1];
        
        for(int i=0; i<n; i++){
            if(s[i]=='.'){
                white[i] = 1;
            }else{
                black[i+1] = 1;
            }
        }
        
        for(int i=0; i<n; i++){
            white[n-i-1] += white[n-i];
            black[i+1] += black[i];
        }
        
        int min = (int)1e6;
        for(int i=0; i<n; i++){
            int sum = white[i+1] + black[i];
            min = Math.min(min, sum);
        }
        
        System.out.println(min);
    }
}


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

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

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

int n;

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

map<ll, int> mp;
const int maxn = 1e5 + 5;
int sz[maxn];
ll d[maxn];
ll dp[maxn];
ll dp1[maxn];
vector<int> G[maxn];

void dfs(int u){
    sz[u] = 1;
    for(auto v : G[u]){
        dfs(v);
        sz[u] += sz[v];
        dp[u] += dp[v] + sz[v];
    }
}

void dfs1(int u){
    ll sum = 0;
    ll sum1 = 0;
    for(auto v : G[u]){
        sum += dp[v];
        sum1 += sz[v];
    }
    for(auto v : G[u]){
        dp1[v] = dp1[u] + sum - dp[v] + sum1 - sz[v] + n - sz[v];
    }
    for(auto v : G[u]){
        dfs1(v);
    }
}

bool check(int root){
    dfs(root);
    dfs1(root);
    for(int i = 1;i <= n;i++){
        if(dp[i] + dp1[i] != d[i])
            return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    priority_queue<pi> pq;
    for(int i = 1;i <= n;i++){
        cin >> d[i];
        mp[d[i]] = i;
        pq.push({d[i], i});
        sz[i] = 1;
    }
    bool flag = true;
    int root = 0;
    while(!pq.empty()){
        pi p = pq.top(); pq.pop();
        ll dis = p.first;
        int id = p.second;
        if(sz[id] == n){
            root = id;
            break;
        }
        ll dis1 = dis - (n - 2 * sz[id]);
        if(mp.find(dis1) == mp.end()){
            flag = false;
            break;
        }else{
            int fa = mp[dis1];
            if(fa == id){
                flag = false;
                break;
            }
            G[fa].push_back(id);
            sz[fa] += sz[id];
        }
    }
    if(flag){
        flag &= check(root);
    }
    if(flag){
        for(int i = 1;i <= n;i++){
            for(auto v : G[i]){
                cout << i << " " << v << endl;
            }
        }
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 19824
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define RANGE(i,n) for(int i=0;i<n;i++)

using namespace std;

signed main() {
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    int A[N][M];
    RANGE(i,M) cin >> B[i];
    RANGE(i,N)RANGE(j,M) cin >> A[i][j];
    int count = 0;
    RANGE(i,N){
        int summention = 0;
        RANGE(j,M) summention += A[i][j] * B[j];
        summention += C;
        if(summention > 0)count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


struct card
{
    string name;
    int score;
};
vector<card> cards;


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

    string n;
    for (int i = 0; i < N; i++)
    {
        cin >> n;
        bool founded = false;
        for(auto& x: cards)
        {
            if (x.name == n)
            {
                founded = true;
                x.score += 1;
                break;
            }
        }
        if (!founded)
        {
            card c;
            c.name = n;
            c.score = 1;
            cards.push_back(c);
        }
    }
    int M;
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> n;
        for(auto& x: cards)
        {
            if (x.name == n)
            {
                x.score -= 1;
                break;
            }
        }
    }
    // トラバースしてmax scoreを見つける　なければ、0
    int max = 0;
    for(auto f: cards)
    {
        if (f.score > max)
        {
            max = f.score;
        }
    }
    cout << max << endl;



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <stdio.h>
#include <sstream>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main() {
  int n, l[100]={};
  cin>>n;
  for(int i=2;i<=n;i++){
    int t=i;
    int a = 2;
    while (t >= a * a) {
        if (t % a == 0) {
            l[a]++;
            t /= a;
        } else {
            a++;
        }
    }
    if(t!=1)l[t]++;
  }
  int n2=0,n4=0,n74=0,n24=0,n14=0;
  for(int i=0;i<100;i++){


    if(l[i]>=74){
      n2++;
      n4++;
      n14++;
      n24++;
      n74++;
    }
    else if(l[i]>=24){
      n2++;
      n4++;
      n14++;
      n24++;
    }
    else if(l[i]>=14){
      n2++;
      n4++;
      n14++;
    }
    else if(l[i]>=4){
      n2++;
      n4++;
    }
    else if(l[i]>=2)n2++;
  }
  int ans=0;
  if(n74>=1)ans+=n74;
  if(n24>=1)ans+=n24*(n2-1);
  if(n14>=1)ans+=n14*(n4-1);
  if(n4>=1)ans+=n4*(n4-1)*(n2-2)/2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

signed main(){
    int x,y;
    cin>>x>>y;
    if(abs(x-y)<=1)cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int n;
  cin>>n;
  vector<int>p(n);
  rep(i,n) cin>>p[i];
  int count=0;
  string ans="YES";
  rep(i,n){
    if(p[i]!=i+1) count++;
  }
  if(count>2) ans="NO";
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 20000000
int n;
int main(){
	cin>>n;
	int r = 0;
	for(int i = 1; i <= n; i++){
		r += i;
		if(r>=n){
			int d = r-n;
			for(int j = 1; j <= i; j++){
				if(j==d) continue;
				cout<<j<<endl;
			}
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

// main is ...
func main() {
	var s string
	fmt.Scan(&s)

	wdays := [...]string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}

	for idx, value := range wdays {
		if value == s {

			fmt.Print(7 - idx)
			return

		}
	}

	fmt.Print(-1)
}



Measured memory_bytes: 512
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  unordered_map<ll, int> um;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    um[tmp]++;
    um[tmp + 1]++;
    um[tmp - 1]++;
  }

  ll ans = 0;
  for (auto& kv : um) {
    if (kv.second > ans) ans = kv.second;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4260
import java.util.*;
class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
  	int n = sc.nextInt();
  	int[] arr = new int[n];
    int max = 0;
  	int sec = 0;
  	for(int i=0;i<n;i++) {
    	arr[i] = sc.nextInt();
    	if(arr[i] > max) {
        	sec = max;
          	max = arr[i];
        }
      	else if(arr[i] > sec){
      		sec = arr[i];
      	}
    }
  	for(int i=0;i<n;i++) {
    	if(arr[i] == max) {
        	System.out.println(sec);
        }
      	else System.out.println(max);
    }
  }
}


Measured memory_bytes: 87252
using System;

public class ABC151C {
  public static void Main(string[] args) {
    var str1 = Console.ReadLine().Split();
    int n = int.Parse(str1[0]);
    int m = int.Parse(str1[1]);
    int[,] ps = new int[n,2];
    int ac = 0;
    int wa = 0;
    for (var i = 0; i < n; i++) {
      ps[i, 0] = ps[i, 1] = 0;
    }
    for (var i = 0; i < m; i++) {
      var str2 = Console.ReadLine().Split();
      int num = int.Parse(str2[0]) - 1;
      if (str2[1].Equals("WA")) {
        ps[num,0] += 1;
      }else if (str2[1].Equals("AC")) {
        if (ps[num,1] == 0) {
          ac++;
          if (ps[num,0] > 0) {
            wa += ps[num,0];
          }
        }
        ps[num,1] += 1;
      }
    }
    
    Console.WriteLine(ac + " " + wa);
    
  }
}

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

signed main() {
	int r, c;
	while (cin >> r >> c && r) {
		vector<vector<int>> v(r, vector<int>(c));
		rep(i, r) rep(j, c) cin >> v[i][j];
		int ans = 0;
		rep(b, 1 << r) {
			int tmp = 0;
			rep(j, c) {
				int bl = 0;
				rep(i, r) bl += v[i][j] ^ ((b >> i) & 1);
				tmp += max(bl, r - bl);
			}
			ans = max(ans, tmp);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3312
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int N;
    cin >> N;
    vector<int> count(40);
    REP(i, N){
        int d;
        cin >> d;
        int p = 0;
        while(d){
            if(d&1){
                ++count[p];
            }
            d>>=1;
            ++p;
        }
    }
    bool flag=true;
    foreach(i, count){
        if((i&1)||N/3*2<i){
            flag=false;
            break;
        }
    }
    cout << (flag?"Yes":"No") << endl;
    return 0;
}



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

int main(){
	int N,count,max=0,judge;
	string S;

	cin >> N;
	cin >> S;

	for(int i=1;i<N-1;i++){
		count=0;
		//入力された文字列を分割
		string X = S.substr(0,i);
		string Y = S.substr(i);
		
		//Xの一文字ずつ比較していく
		for(int j=0;j<X.size();j++){
			judge=0;
			//X内に同じ文字があればスキップ
			if(j>=1){
				for(int l=0;l<j;l++){
					if(X[j]==X[l]){
						judge=1;
						break;
					}
				}
				if(judge==1)continue;
			}

			//比較してX,Y同じならbreak
			for(int k=0;k<Y.size();k++){
				if(X[j]==Y[k]){
					count++;
					break;
				}
			}
		}
		if(max<count){
		max=count;
		}
	}

	cout << max << endl;
	return 0;
}

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

int main(){
	int H , W;
	int i, j;
	while(1){
		char fig1[301]={0};
		char fig2[301]={0};
		cin >> H >> W;
		if(H==0 && W==0) break;
		for(i=0 ; i<W ; i+=2){
			fig1[i]='#';
		}
		for(i=1 ; i<W ; i+=2){
			fig1[i]='.';
		}
		for(i=0 ; i<W ; i+=2){
			fig2[i]='.';
		}
		for(i=1 ; i<W ; i+=2){
			fig2[i]='#';
		}
		if (H%2==0){
			for(i=0 ; i<H/2 ; i++){
				cout << fig1 << endl;
				cout << fig2 << endl;
			}
		} else {
			for(i=0 ; i<H/2+1 ; i++){
				cout << fig1 << endl;
				if(i!=H/2){
					cout << fig2 << endl;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
using System;
using System.Linq;

class Program {
    static void Main() {
        string[] stdin = Console.ReadLine().Split();
        int n = int.Parse(stdin[0]);
        int m = int.Parse(stdin[1]);
        int[][] a = new int[n][];
        for(int i = 0; i < n; i++) a[i] = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        int[] b = new int[m];
        for(int i = 0; i < m; i++) b[i] = int.Parse(Console.ReadLine());
        for(int i = 0; i < n; i++) {
            int ans = 0;
            for(int j = 0; j < m; j++) ans += a[i][j] * b[j];
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18368
n=int(input())
a=[[ [0 for i in range(10)] for j in range(3) ] for k in range(4)]
for i in range(n):
	b,f,r,v=map(int,input().split())
	a[b-1][f-1][r-1]+=v

for i in range(4):
	for j in range(4):
		for k in range(10):
			if j==3:
				if i<3:
					print("##",end="")
				else:
					break
			else:
				print(" "+str(a[i][j][k]),end="")
			if k==9:
				print("")



Measured memory_bytes: 5628
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>
using namespace std;
int main(void){
    string in;
    string out="";
    getline(cin,in);
    for(int s=0;s<in.length();s++){
        string moji;
        moji=in.substr(s,5);
        if(moji=="apple"){
            out+="peach";
            s+=4;
        }else if(moji=="peach"){
            out+="apple";
            s+=4;
        }else{
            out+=in[s];
        }
    }
    cout<<out<<endl;
    return 0;
}

Measured memory_bytes: 1188
N,M = list(map(int,input().split()))
S = [0]*N #間違った数を入れる。正解は-1
ac = 0
wa = 0
for i in range(M):
    p,s = input().split()
    p = int(p)
    #未正解の時
    if S[p-1] != -1:
        #間違えると
        if s == "WA":
            S[p-1] += 1
        #正解したら、
        else:
            wa += S[p-1]
            ac += 1
            S[p-1] = -1
    #すでに正解している時
    else:
        pass
    """
    print("p,s=",p,s)
    print("i",i)
    print(S)
    print("ac,wa=",ac,wa)
    """
print(ac,wa)

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

int main() {
  int n; 
  cin>>n;
  int j;
  for(int i=1;i<=n;i++){
    j=i;
    if(i%3==0){cout << " " << i;continue;}
    while(j>0){if(j%10==3){cout << " " << i;break;}j/=10;}
    }  
  cout << endl;    
  return 0;
}



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

const int INF = 10000;

int main(){
    int n, T;
    cin >> n >> T;

    int c[n], t[n];
    for (int i = 0; i < n; i++){
        cin >> c[i] >> t[i];
    }

    int c_min = INF;
    for (int i = 0; i < n; i++){
        if (t[i] <= T && c[i] < c_min){
            c_min = c[i];
        }
    }

    if (c_min == INF){
        cout << "TLE" << endl;
    } else {
        cout << c_min << endl;
    }

    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

sa = [0]
sb = [0]
ta = [0]
tb = [0]

for i in S:
    if i == "A":
        sa.append(sa[-1] + 1)
        sb.append(sb[-1])
    else:
        sa.append(sa[-1])
        sb.append(sb[-1] + 1)

for i in T:
    if i == "A":
        ta.append(ta[-1] + 1)
        tb.append(tb[-1])
    else:
        ta.append(ta[-1])
        tb.append(tb[-1] + 1)


q = int(input())

for i in range(q):

    a,b,c,d = map(int,input().split())

    one = ((sa[b] - sa[a-1]) - (sb[b] - sb[a-1]))
    two = ((ta[d] - ta[c-1]) - (tb[d] - tb[c-1]))

    if  one % 3 == two % 3:
        print ("YES")
    else:
        print ("NO")


Measured memory_bytes: 56924
#include<iostream>
using namespace std;
int a,b;
string s1,s2,s;
int main(){
	cin>>s1>>s2;
	cin>>a>>b;
	cin>>s;
	if (s==s1) --a;
	if (s==s2) --b;
	printf ("%d %d\n",a,b);
	return 0;
}

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

int main()
{
	char str[20];
	char* p=str;
	cin >> str;
	int count = 0;
	while(*p != NULL){
		p++;
		count++;
	}
	count--;
	for(int i=count;i>=0;i--){
		cout << str[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
	int a,b,s;
	
	for(a=1;a<=9;a++){
		for(b=1;b<=9;b++){
			s=a*b;
			printf("%dx%d=%d\n",a,b,s);
		}	
	}
	return 0;
}

Measured memory_bytes: 924
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define PI 3.1415926535897932384626433
using namespace std;
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        double ax,ay,ar,bx,by,br;
        cin>>ax>>ay>>ar>>bx>>by>>br;
        double dis=sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
        if(dis+ar<br)cout<<"-2"<<endl;
        else if(dis+br<ar)cout<<"2"<<endl;
        else if(ar+br<dis)cout<<"0"<<endl;
        else cout<<"1"<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;


int main()
{
    ios_base::sync_with_stdio(0);
    
    ll n,d;
    cin>>n>>d;
    ll i,x,y,cnt=0;
    for(i=0;i<n;++i){
        cin>>x>>y;
        if(x*x+y*y<=d*d){
            cnt++;
        }
    }
    cout<<cnt;
}



Measured memory_bytes: 3652
using System;
using System.Collections.Generic;

namespace abc135_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var a = CIn.ReadIntArray(n);

      var diff = 0;

      for (var i = 0; i < n; i++)
      {
        if (a[i] != i + 1)
        {
          if (diff == 0)
          {
            diff = a[i];
          }
          else
          {
            if (diff == i + 1)
            {
              diff = -1;
            }
            else
            {
              Console.WriteLine("NO");
              return;
            }
          }
        }
      }
      
      if (diff == -1 || diff == 0)
      {
        Console.WriteLine("YES");
      }
      else
      {
        Console.WriteLine("NO");
      }
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

struct edge {
    int to, cost;
};

const int mxN = 1e5 + 5;
V<edge> g[mxN];
ll dist[mxN] = {0};

// dist[i] := i から最も遠い
void dfs1(int idx, int par) {
    for(auto& e : g[idx]) {
        if(e.to == par) continue;
        dfs1(e.to, idx);
        chmax(dist[idx], dist[e.to] + e.cost);
    }
}

int dfs2(int idx, int d_par, int par) {
    V<P> d_child;
    // d_child := {a, b} (aは頂点bを根と見たときの部分木の,bから葉までの最大パス)
    d_child.emplace_back(0, -1);
    for(auto &e : g[idx]) {
        if(e.to == par) d_child.emplace_back(d_par + e.cost, e.to);
        else d_child.emplace_back(e.cost + dist[e.to], e.to);
    }
    sort(rall(d_child));
    int ret = d_child[0].first + d_child[1].first;
    // ここまでで頂点idxを通るパスの最大値が求まった(= ret)

    //ここから再帰的に帰っていく
    for(edge &e : g[idx]) {
        // d_par は伝播する頂点以外を根として見たときのmax 
        if(e.to == par) continue;
        chmax(ret, dfs2(e.to, d_child[d_child[0].second == e.to].first, idx));
    }

    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    rep(i, n-1) {
        int a, b, w;
        cin >> a >> b >> w;
        g[a].push_back((edge){b, w});
        g[b].push_back((edge){a, w});
    }
    dfs1(n/2, -1);
    int ans = dfs2(n/2, 0, -1);
    cout << ans << endl;

}


Measured memory_bytes: 20340
import sys

sys.setrecursionlimit(10**6)

def dfs(n, before):
    global cnt, K, ans, flag
    ints = int(before[-1])
    int1s = ints - 1; ints1 = ints + 1

    if int1s >= 0:
        after1s = before + str(int1s)
        if n == 1: 
            cnt += 1
        if cnt == K and flag == 0:
            ans = after1s; flag = 1
            return
        if n >= 2:
            dfs(n-1, after1s)
    
    afters = before + str(ints)
    if n == 1:
        cnt += 1
    if cnt == K and flag == 0:
        ans = afters; flag = 1
        return
    if n >= 2:
        dfs(n-1, afters)

    if ints1 <= 9:
        afters1 = before + str(ints1)
        if n == 1:
            cnt += 1
        if cnt == K and flag == 0:
            ans = afters1; flag = 1
        if n >= 2:
            dfs(n-1, afters1)


def main():
    global cnt, K, ans, flag
    K = int(input())
    if K <= 9:
        print(K)
        return
    cnt = 9
    flag = 0
    for n in range(1, 13):
        for s in range(1, 10):
            dfs(n, str(s))
            if flag == 1:
                break
        if flag == 1:
            break
    print(ans)

if __name__ == "__main__":
    main()


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e18;

int a[60][60];

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        ld x;
        for(int i=0;i<n;i++)
        {
            cin>>x;
            x *= 1e9;
            int y = round(x);
            int cn_2 = 0,cn_5 = 0;
            while(y%2 == 0)cn_2++,y/=2LL;
            while(y%5 == 0)cn_5++,y/=5LL;
            a[cn_2][cn_5]++;
        }
        int ans = 0;
        for(int i=0;i<60;i++)for(int j=0;j<60;j++)for(int ii=0;ii<60;ii++)for(int jj=0;jj<60;jj++)
        {
            if(i == ii && j == jj)
            {
                if(i>=9 && j>=9 && a[i][j])
                ans += (a[i][j]*(a[i][j]-1));
            }
            else
            {
                int cn_2 = i+ii;
                int cn_5 = j+jj;
                if(min(cn_2,cn_5) >= 18 && a[i][j] && a[ii][jj])
                ans += a[i][j]*a[ii][jj];
            }
        }
        cout<<ans/2LL<<endl;
    }
    return 0;
}


Measured memory_bytes: 3780
// Problem : B - Contest with Drinks Easy
// Contest : AtCoder - AtCoder Beginner Contest 050
// URL : https://atcoder.jp/contests/abc050/tasks/abc050_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	long long sum = 0;
	cin >> n;
	vector<int> t(n);
	for(auto &it:t){
	    cin >> it;
	    sum+=it;
	}
	vector<int> a(n);
	for(int i =0; i < n; i++){
	    a[i] = sum-t[i];
	}
	int m;
	cin >> m;
	int p, x;
	for(int i = 0; i<m; i++){
	    cin >> p >> x;
	    cout << a[p-1]+x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
	int N;
	int *a, *b, *c, *ans;
	scanf("%d", &N);

	a = new int[N];
	b = new int[N];
	c = new int[N];
	ans = new int[N];
	for(int i=0; i<N; i++) scanf("%d %d %d",&a[i],&b[i],&c[i]);

	for(int i=0; i<N; i++) {
		if(a[i]>=b[i] && a[i]>=c[i]) {
			if(b[i]*b[i]+c[i]*c[i] == a[i]*a[i]) ans[i] = 1;
			else ans[i] = 0;
		}
		if(b[i]>=a[i] && b[i]>=c[i]) {
			if(a[i]*a[i]+c[i]*c[i] == b[i]*b[i]) ans[i] = 1;
			else ans[i] = 0;
		}
		if(c[i]>=b[i] && c[i]>=a[i]) {
			if(b[i]*b[i]+a[i]*a[i] == c[i]*c[i]) ans[i] = 1;
			else ans[i] = 0;
		}
	}

	for(int i=0; i<N; i++) {
		if(ans[i] == 0) printf("NO\n");
		else printf("YES\n");
	}

	delete[] a;
	delete[] b;
	delete[] c;
	delete[] ans;

	return 0;
}


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

int main() {
	int lo[12];
	for (int i = 0;i < 12;i++) cin >> lo[i];
	sort(lo, lo + 12);

	if (lo[0] == lo[3] && lo[4] == lo[7] && lo[8] == lo[11])cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int a[3][3];
  REP(i, 3) {
    REP(j, 3) {
      cin >> a[i][j];
    }
  }
  int n;
  cin >> n;

  VI v(n);
  REP(i, n) {
    cin >> v[i];
  }

  REP(k, n) {
    REP(i, 3) {
      REP(j, 3) {
        if (v[k] == a[i][j]) {
          a[i][j] = 0;
        }
      }
    }
  }




  //たて
  REP(i, 3) {
    if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) {
      ANS("Yes");
      return 0;
    }
  }

  REP(j, 3) {
    if (a[0][j] == 0 && a[1][j] == 0 && a[2][j] == 0) {
      ANS("Yes");
      return 0;
    }
  }

  if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
    ANS("Yes");
    return 0;
  }

  if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
    ANS("Yes");
    return 0;
  }

  ANS("No");

  return 0;
}


Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N = int(input())
S = input()

left_W = [0]*N
right_E = [0]*N

for i in range(N-1):
    if S[i]=='W':
        left_W[i+1] = left_W[i]+1
    else:
        left_W[i+1] = left_W[i]

for i in range(N-1,0,-1):
    if S[i]=='E':
        right_E[i-1] = right_E[i]+1
    else:
        right_E[i-1] = right_E[i]

ans = N
for i in range(N):
    ans = min(ans, left_W[i]+right_E[i])

print(ans)

Measured memory_bytes: 26512
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
// run : ctrl + c 

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

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

   
   int k;
   cin>>k;
   k--;
   cout <<a[k] << endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto V=vecin(N);
	vector<int> X(N);
	for(int i=0;i<N;i++) X[V[i]-1] = i;
	
	int ans=1,sum=1;
	for(int i=0;i<N-1;i++){
		if(X[i]<X[i+1]){
			sum++;
		}
		else{
			ans = max(ans,sum);
			sum = 1;
		}
		ans = max(ans,sum);
	}
	
	out(N-ans);
	return 0;
}


Measured memory_bytes: 1792
# AFTER EDITORIAL


def solve(k, ls):
    n = len(ls)
    i0 = 1
    i1 = max(ls)
    i = (i0 + i1) // 2
    while i0 < i1:
        m = 0
        for a in ls:
            m += (a // i) - int(a % i == 0)
        if m <= k:
            i1 = i
            i = (i0 + i1) // 2
        else:
            i0 = i + 1
            i = (i0 + i1) // 2
    return i


def main(istr, ostr):
    n, k = list(map(int, istr.readline().strip().split()))
    ls = list(map(int, istr.readline().strip().split()))
    result = solve(k, ls)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

int n;
int t[20][20];
lint dp[100000];
int lg[100000];


int main () {
	read(n);
	FOR(i,0,n) FOR(j,0,n) {
		make(a); t[i][j] = a;
	}
	FOR(j,0,16) lg[1<<j] = j;
	dp[0] = 0;
	FOR(i,1,1<<n) {
		int mask = i;
		VI x;
		while (mask) {
			x.pb(lg[mask&(-mask)]);
			mask ^= (mask & (-mask));
		}
		int m = x.size();
		lint pos = 0;
		FOR(ii,0,m) FOR(j,ii+1,m) pos += t[x[ii]][x[j]];
		FOR(j,1,1<<m-1) {
			int maska = 0;
			int mask = j;
			while (mask) {
				int kto = lg[mask&(-mask)];
				maska ^= (1<<x[kto]);
				mask ^= (mask & (-mask));
			}
			pos = max(pos, dp[maska] + dp[i^maska]);
		}
		dp[i] = pos;
	}
	printf("%lld\n", dp[(1<<n)-1]);
}	





Measured memory_bytes: 768