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

using namespace std;

bool isPairwise = true;
unordered_map<long long int, long long int> m;
void factors(int a) {
    if(isPairwise == false) {
        return;
    } else {
        if(m[a] && a != 1) {
            isPairwise = false;
            return;
        } else {
            m[a] = 1;
        }
        for(int i = 2; i*i < a; i++) {
            int f1,f2;
            if(a%i == 0) {
                f1 = i;
                f2 = a/i;
                if(f1 == f2) {
                    if(m[f1]) {
                        isPairwise = false;
                        return;
                    } else {
                        m[f1] = 1;
                    }
                } else {
                    if(m[f1]) {
                        isPairwise = false;
                        return;
                    } else {
                        m[f1] = 1;
                    }

                    if(m[f2]) {
                        isPairwise = false;
                        return;
                    } else {
                        m[f2] = 1;
                    }
                }
            }
        }
    }
}

int main() {
    int n;
    cin>>n;
    long long int a[n];
    for(int i = 0; i < n; i++) {
        cin>>a[i];
    }
    long long int sg = a[0];
    factors(a[n-1]);
    for(int i = 0; i < n-1; i++) {
        factors(a[i]);
        sg = __gcd(sg, a[i+1]);
    }
    if(isPairwise) {
        cout<<"pairwise coprime"<<endl;
    } else if(sg == 1) {
        cout<<"setwise coprime"<<endl;
    } else {
        cout<<"not coprime"<<endl;
    }
    return 0;
}

Measured memory_bytes: 11424
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;

#define REP(var, count) for(int var=0; var<count; var++)

int main(void) {
	int N;
	cin >> N;
	
	vector<int> rin[105];
	int ans[105];
	
	REP(i, N) {
		int u, k;
		cin >> u >> k;
		
		REP(j, k) {
			int c;
			cin >> c;
			
			rin[u].push_back(c);
		}
		
		ans[i] = -1;
	}
	ans[N] = -1;
	
	ans[1] = 0;
	queue<int> que;
	que.push(1);
	
	while(que.size()) {
		int s = que.front();
		que.pop();
		
		//cerr << "checking " << s << endl;
		
		REP(j, rin[s].size() ) {
			//cerr << "edge to " << rin[s][j] << endl;
			if ( ans[rin[s][j]] == -1 ) {
				ans[rin[s][j]] = ans[s] + 1;
				que.push(rin[s][j]);
			}
		}
	}
	
	for(int i=1; i<=N; i++) {
		cout << i << " " << ans[i] << endl;
	}
}

Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF = 1e18L + 5;
const int nax=1e5+5;
vector<int> graph[nax];
vector<int> dist(nax,0);
bool visited[nax];
int indegree[nax];

void dfs(int a){
    visited[a]=true;
    for(auto edje:graph[a]){
        dist[edje]=max(dist[edje],dist[a]+1);
        indegree[edje]--;
        if(indegree[edje]==0){
            dfs(edje);
        }
    }
}
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
        indegree[y]++;
    }
    for(int i=1;i<=n;i++){
        if(!visited[i] && indegree[i]==0)
            dfs(i);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dist[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9728
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	int n, i, j;
	cin >> n;
	vi a(n);
	int m = inf, M = -1;
	set<int> st;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		st.insert(a[i]);
		m = min(m, a[i]);
		M = max(M, a[i]);
	}
	if (st.size() >= 3) {
		cout << "No" << endl;
		return 0;
	}
	else if (st.size() == 1) {
		int m = a[0];
		if (m == n - 1) {
			cout << "Yes" << endl;
		}
		else if (2 * m <= n) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
	}
	else {
		if (M - m != 1) {
			cout << "No" << endl;
			return 0;
		}
		vi b(n);
		int cnt = 0;
		for (i = 0; i < n; i++) {
			if (a[i] == m) {
				cnt++;
			}
		}
		m -= (cnt - 1);
		n -= cnt;
		if (2 * m <= n && m > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
}


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

int main() {
    int A, B;
    cin >> A >> B;

    vector<bool> existed(3, false);

    existed[A - 1] = true;
    existed[B - 1] = true;

    rep(i, 3) {
        if (!existed[i]) {
            cout << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define mper make_pair
#define PI 3.14159
#define fe first
#define se second
#define ll long long
//#define forik(i, a, b) for(ll i = a; i <= b; ++i)
#define vl vector<ll>
#define pll pair<ll, ll>
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
using namespace std;

const int MAXN = 2e5 + 100;
saken s;

int main() {

mal

cin >> s;

int ans = 0, key = 0;

for(int i = 0; i < s.sz(); ++i) {

    if(s[i] == 'S') {key++;}
    else {key--;}

    if(key < 0) {ans++; key = 0;}

}

cout << ans + max(key, 0);

return 0;
}


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

int main() {
  int N, A = 0, W = 0, T = 0, R = 0;
  string S;
  char s;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> S;
    s = S.at(0);
    if (s == 'A') A++;
    else if (s == 'W') W++;
    else if (s == 'T') T++;
    else if (s == 'R') R++;
  }

  cout << "AC" << " x " << A << endl;
  cout << "WA" << " x " << W << endl;
  cout << "TLE" << " x " << T << endl;
  cout << "RE" << " x " << R << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
  long long n,m; cin >> n >> m;
  if(abs(n-m)>=2) cout << 0 << endl;
  if(n==m){
    long long ans = 1;
    for(long long i=n;i>=1;i--) ans = ans * i % 1000000007;
    cout << ans * ans * 2 % 1000000007;
  }
  if(abs(m-n)==1){
    long long mini = min(n,m);
    long long maxi = max(n,m);
    long long ans1 = 1, ans2 = 1;
    for(long long i=maxi;i>=1;i--) ans1 = ans1 * i % 1000000007;
    for(long long i=mini;i>=1;i--) ans2 = ans2 * i % 1000000007;
    cout << ans1 * ans2 % 1000000007 << endl;
  }
  return 0;
}

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

struct Card {
  char suit, value;
};

void printvec(Card[], int);
void bubble(Card[], int);
void select(Card[], int);
bool isStable(Card[], Card[], int);

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

  Card c1[n], c2[n];
  for (int i = 0; i < n; i++) {
    cin >> c1[i].suit >> c1[i].value;
    c2[i] = c1[i];
  }

  bubble(c1, n);
  printvec(c1, n);
  cout << "Stable" << endl;

  select(c2, n);
  printvec(c2, n);

  cout << (isStable(c1, c2, n) ? "S" : "Not s") << "table" << endl;
}

void printvec(Card a[], int n) {
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << a[i].suit << a[i].value;
  }
  cout << endl;
}

void bubble(Card a[], int n) {
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      if (a[j - 1].value > a[j].value) {
        swap(a[j], a[j - 1]);
      }
    }
  }
}

void select(Card a[], int n) {
  for (int i = 0; i < n; i++) {
    int minj = i;
    for (int j = i; j < n; j++) {
      if (a[j].value < a[minj].value) {
        minj = j;
      }
    }
    swap(a[i], a[minj]);
  }
}

bool isStable(Card a[], Card b[], int n) {
  bool stable = true;
  for (int i = 0; i < n; i++) {
    if (a[i].suit != b[i].suit) {
      stable = false;
    }
  }
  return stable;
}


Measured memory_bytes: 3096
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main(){
   int a,b;
   cin>>a>>b;
   if(a>=10||b>=10)
    cout<<-1<<endl;
    else
        cout<<a*b<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    long long A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    long long distance = abs(A - B);
    if(W >= V){
        cout << "NO" << endl;
        return 0;
    }
    long long ddistance = V - W;
    for (int i = 1; i <= T; i++)
    {
        distance -= ddistance;
        if (distance <= 0)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
    }


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

int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    for(int i = 0; i <= N - 2; i++){
        if(S[i] == 'A' &&S[i+1] == 'B' && S[i+2] == 'C' ){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, sum;
  sum = 0;
  cin >> n;
  
  vector<int> numb(n);
  for(int i = 0; i < n ; i++){
    cin >> numb.at(i);
  }
  for(int i = 1; i < n - 1; i++){
  if (numb.at(i-1) < numb.at(i) && numb.at(i) < numb.at(i+1)){
    sum++;
  }
  else if (numb.at(i-1) > numb.at(i) && numb.at(i) > numb.at(i+1)){
    sum++;
  }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

struct P{double x, y;};

ll N;
vector<P> p;


double dist(P p1,P p2){
  double c1=p1.x-p2.x;
  double c2=p1.y-p2.y;
  return sqrt(c1*c1+c2*c2);
}

double f(double x,double y){
  double res=0;
  REP(i,N){
    res=max(res, dist((P){x,y},p[i]));
  }
  return res;
}

double g(double x){
  double l=0,r=1000;
  REP(hoge,80){
    double c1=(l*2+r)/3;
    double c2=(l+2*r)/3;
    if(f(x,c1)>f(x,c2))l=c1;
    else r=c2;
  }
  return f(x,l);
}



int main(){
  cin>>N;
  p=vector<P>(N);
  REP(i,N)cin>> p[i].x >> p[i].y;

  double l=0,r=1000;
  REP(hoge,80){
    double c1=(l*2+r)/3;
    double c2=(l+2*r)/3;
    if(g(c1)>g(c2))l =c1;
    else r=c2;
  }
  double ans=g(l);
  printf("%.10f\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

ll dp[402][402];

ll dfs(int left, int right, int n, ll* a, ll* accum)
{
  if(dp[left][right] != -1)
  {
    return dp[left][right];
  }

  if(left+1 == right)
  {
    dp[left][right] = 0;
    return dp[left][right];
  }
  ll accum_cost = accum[right] - accum[left];
  ll min_cost = 1ll << 62;
  for(int i=left+1;i<right;++i)
  {
    ll cost_left = dfs(left, i, n, a, accum);
    ll cost_right = dfs(i, right, n, a, accum);
    min_cost = min(min_cost, cost_left + cost_right);
  }

  dp[left][right] = min_cost + accum_cost;
  return dp[left][right];
}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a[n] = {};
    ll accum[n+1] = {};
    ll tmp = 0;
    accum[0] = 0;
    FILL(dp, -1);
    for(int i=0;i<n;++i)
    {
      cin >> a[i];
      tmp += a[i];
      accum[i+1] = tmp;
    }

    cout << dfs(0, n, n, a, accum) << endl;
}

Measured memory_bytes: 1664
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=A.pop(-1)
if 0 in A:
    print(0)
else:
    for i in range(N-1):
        ans=ans*A[N-(i+2)]
        if ans > (10**18): break
        if ans == 0: break
    print(ans if ans<=10**18 else -1)

Measured memory_bytes: 21592
N,K = map(int,input().split())
C = {}
A = []
for _ in range(N):
    a,b = map(int,input().split())
    if a not in C:
        C[a] = 0
    C[a] += b
    A.append(a)
A = sorted(list(set(A)))
cnt = 0
for i in range(len(A)):
    cnt += C[A[i]]
    if cnt>=K:
        print(A[i])
        break


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
print(max(a) - min(a))

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

// f[i] := s[i] + s[i+1] + ... s[n-2];
int f[100001] = {0};

// f[0..s.size()] をあらかじめ計算しておく. 計算量はO(n)
void ini(vector<int>& s){
	int res = 0;
	for(int i=0 ; i < s.size() ; i++ ){
		res += s[i];
	}
	f[0] = res;
	for(int i=1 ; i < s.size() ; i++ ){
		f[i] = f[i-1] - s[i-1];
	}
}

// s[i] + s[i+1] + .. s[j] を返す.
int sum(int i, int j){
	return f[i] - f[j+1];
}

// 
int add(int k, int a){
	if( a > 0 ){
		return sum( k , k+a-1 );
	}
	return sum( k+a , k-1 );
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> s(n-1);
	for(int i=0 ; i < n-1 ; i++ ){
		cin >> s[i];
	}
	vector<int> a(m);
	for(int i=0 ; i < m ; i++ ){
		cin >> a[i];
	}
	
	ini(s);
	// k := 今の宿の位置, ans := 解
	int ans = 0, k = 0;
	for(int i=0 ; i < m ; i++ ){
		ans = (ans + add(k,a[i])) % 100000;
		k += a[i];
	}
	cout << ans << endl;
}

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

int main(void){
    string taro, hanako;
    int taropoint = 0, hanakopoint = 0;
    int n, i;

    cin >> n;
    for(i = 0; i < n; i++){
        cin >> taro >> hanako;
        
        if(taro > hanako) taropoint += 3;
        else if(taro == hanako){
            taropoint += 1;
            hanakopoint += 1;
        }
        else hanakopoint += 3;
    }

    cout << taropoint << " " << hanakopoint << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int n,a,b;
vector<int> h;

bool enough(ll mid, ll k) {
  REP(i,n) {
    ll nh = h[i]-k;
    if (nh > 0) mid -= nh/(a-b) + (nh%(a-b) > 0);
  }
  return 0 <= mid;
}

int main() {
  IOS;
  cin >> n >> a >> b;
  h.resize(n);
  REP(i,n) cin >> h[i];

  sort(ALL(h));

  int ng = 0, ok = h[n-1]/b+1;
  while(abs(ok-ng) > 1) {
    ll mid = (ok+ng)/2;
    ll key = b * mid;
    if (enough(mid, key)) ok = mid;
    else ng = mid;
  }

  COUT(ok);
  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int count=0;
  for(int i=0;i<n-2;i++){
    if((a[i+1]-a[i])*(a[i+1]-a[i+2])<0)
      count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		Integer A[] = {1, 3, 5, 7, 8, 10, 12};
		Integer B[] = {4, 6, 9, 11};
		Integer C[] = {2};
		if(Arrays.asList(A).contains(x) && Arrays.asList(A).contains(y)) {
			System.out.println("Yes");
			return;
		}
		if(Arrays.asList(B).contains(x) && Arrays.asList(B).contains(y)) {
			System.out.println("Yes");
			return;
		}
		if(Arrays.asList(C).contains(x) && Arrays.asList(C).contains(y)) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}


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

int main() {
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	   cin>>a[i];
	   
	   int ans=INT_MAX;
	   int c=0;
	   for(int i=1;i<=100;i++){
	         c=0;
	   	for(int j=0;j<n;j++)
	   		c+=(a[j]-i)*(a[j]-i);
	   		
	   	  ans=min(ans,c);
	   	  
	  
	   }
	   cout<<ans<<endl;
	
	   
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;

	vector<vector<char>> pic(H + 2, vector<char>(W + 2));

	for (int i = 1; i < H+1; i++) {
		for (int j = 1; j < W+1; j++) {
			cin >> pic.at(i).at(j);
		}
	}

	for (int k = 0; k < W+1; k++) {
		pic.at(0).at(k) = '#';
	}

	for (int l = 0; l < W+1; l++) {
		pic.at(H + 1).at(l) = '#';
	}

	for (int m = 0; m < H + 2; m++) {
		pic.at(m).at(0) = '#';
		pic.at(m).at(W + 1) = '#';
	}

	for (int n = 0; n < H + 2; n++) {
		if (n > 0) cout << endl;
		for (int o = 0; o < W + 2; o++) {
			cout << pic.at(n).at(o);
		}
	}
}

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

int main()
{
int n, x;
cin >> n >> x;
vector<int> d(n+1);
d[0] = 0;
for(int i = 0; i < n; i++)
{
	int x;
	cin >> x;
	d[i+1] = d[i] + x;
}
int ans = 0;
for(int i = 0; i <= n; i++)
{
	if(d[i] <= x)
	{
		ans++;
	}
}
cout << ans << endl;
return 0;
}


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

bool desH(char c, char d){
	if ((c=='N' && d=='S') || (c=='S' && d=='N') || (c=='o' && d=='o')) return true;
	return false;
}
bool desV(char c, char d){
	if ((c=='E' && d=='W') || (c=='W' && d=='E') || (c=='o' && d=='o') ) return true;
	return false;
}

int main(){
	int i;
	char ruta[2000];
	while(scanf("%s",ruta)!=EOF){
		char auxH='o',antH='o',auxV='o',antV='o';
		bool h=true,v=true;
		i=0;
		while(ruta[i]!='\0'){
			if( (ruta[i]=='N') || (ruta[i]=='S')){

				if(antH!=ruta[i]){

					h=h?false:true;
					auxH=antH;
					antH=ruta[i];
				}
			}
			if( (ruta[i]=='E') || (ruta[i]=='W')){
				if(antV!=ruta[i]){
					v=v?false:true;
					auxV=antV;
					antV=ruta[i];
				}
			}
			i++;
		}

		if(desH(auxH,antH) && desV(auxV,antV)) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

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

	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++) {
		bool flag = false;
		if(i % 3 == 0) {
			flag = true;
		}
		int j = i;
		while(1) {
			int r = j % 10;
			j /= 10;
			if(r == 3) {
				flag = true;
				break;
			}
			if(j == 0) break;
		}
		if(flag) cout << " " << i;
	}
	
	cout << "\n";
	
	return 0;
}

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

#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )
const int INF = 1e15;

struct Edge {
  int to, cost;
  Edge(int to, int cost): to(to), cost(cost) {}
};

int N, M;
vector<vector<Edge> > G;
vector<int> add[2];
bool zero = false;

void dfs(int v, int s, bool f) {
  if ( add[f][v] != INF ) {
    if ( add[f][v] != s ) zero = true;
    return;
  }
  add[f][v] = s;
  for ( Edge &e: G[v] ) {
    dfs(e.to, e.cost-s, !f);
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  G.resize(N);
  add[0].resize(N, INF);
  add[1].resize(N, INF);
  REP(i, M) {
    int u, v, s;
    cin >> u >> v >> s;
    u--; v--;
    G[u].push_back(Edge(v, s));
    G[v].push_back(Edge(u, s));
  }

  dfs(0, 0, 0);

  if ( zero ) {
    cout << 0 << endl;
    return 0;
  }
  /* REP(i, N) {
    cout << add[0][i] << " " << add[1][i] << endl;
  } */
  int ma = INF;
  int mi = 0;
  set<int> all;
  REP(i, N) {
    if ( add[0][i] != INF && add[1][i] != INF ) {
      if ( add[0][i] == add[1][i] ) {
        cout << 0 << endl;
        return 0;
      }
      if ( (add[1][i]-add[0][i])/2 <= 0 ) {
        cout << 0 << endl;
        return 0;
      }
      all.insert((add[1][i]-add[0][i])/2);
    }
    if ( add[0][i] != INF ) mi = max(mi, -add[0][i]);
    if ( add[1][i] != INF ) ma = min(ma, add[1][i]);
  }
  if ( add[1][0] != INF ) {
    if ( add[1][0] > 0 && add[1][0]%2 == 0 ) {
      int t = add[1][0]/2;
      if ( mi < t && t < ma ) cout << 1 << endl;
      else cout << 0 << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  if ( all.size() == 1 ) {
    cout << 1 << endl;
  }
  else if ( all.size() > 1 ) {
    cout << 0 << endl;
  }
  else cout << max(0LL, ma-mi-1) << endl;

  return 0;
}


Measured memory_bytes: 15872
#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 int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,t;cin>>n>>t;
    vin a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    vvin dpa(n+1,vin(t+1)),dpb(n+1,vin(t+1));//dpaは最後の料理を時間をはみ出して食べるときのmax dpbは時間j以内に食べ終わるという条件下でのmax
    rep(i,n)rep2(j,1,t+1){
        dpb[i+1][j]=dpb[i][j];
        if(j>=a[i])dpb[i+1][j]=max(dpb[i+1][j],dpb[i][j-a[i]]+b[i]);
        dpa[i+1][j]=max(dpa[i][j],dpb[i+1][j]);
        //i+1番目の料理を最初と最後どっちにするかで場合分け
        if(j>=a[i])dpa[i+1][j]=max(dpa[i+1][j],dpa[i][j-a[i]]+b[i]);
        dpa[i+1][j]=max(dpa[i+1][j],dpb[i][j-1]+b[i]);
    }
    cout<<dpa[n][t]<<endl;
}

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

string goX(bool, int);
string goY(bool, int);

int main()
{
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  bool isTargetRight = (tx > sx), isTargetUp = (ty > sy);

  int diffX = abs(tx - sx), diffY = abs(ty - sy);

  string result;

  result += goX(!isTargetRight, 1);
  result += goY(isTargetUp, diffY + 1);
  result += goX(isTargetRight, diffX + 1);
  result += goY(!isTargetUp, diffY + 1);
  result += goX(!isTargetRight, diffX);
  result += goY(isTargetUp, diffY);
  result += goX(isTargetRight, diffX);
  result += goX(isTargetRight, 1);
  result += goY(!isTargetUp, diffY + 1);
  result += goX(!isTargetRight, diffX + 1);
  result += goY(isTargetUp, 1);

  cout << result << endl;
}

string goX(bool toRight, int length)
{
  string answer;

  if (toRight)
  {
    for (int i = 0; i < length; i++)
    {
      answer += 'R';
    }
  }
  else
  {
    for (int i = 0; i < length; i++)
    {
      answer += 'L';
    }
  }

  return answer;
}

string goY(bool toUp, int length)
{
  string answer;

  if (toUp)
  {
    for (int i = 0; i < length; i++)
    {
      answer += 'U';
    }
  }
  else
  {
    for (int i = 0; i < length; i++)
    {
      answer += 'D';
    }
  }

  return answer;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
requests=[]
ans=[]
for i in range(M):
    a,b=map(int,input().split())
    requests.append((a,b))
requests = sorted(requests, key=lambda t:t[1])
for req in requests:
    if len(ans) > 0:
        if req[0] <= ans[-1] and ans[-1] < req[1]:
            continue
    ans.append(req[1]-1)
print(len(ans))


Measured memory_bytes: 57688
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int r = saori.saori_hayami();
		if(n >= 10){
			System.out.println(r);
		} else {
			System.out.println(100*(10-n)+r);
		}
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <memory>
#include <climits>

constexpr long long MOD = 1000000007;

int gcd(int m, int n)
{
  return n == 0 ? m : gcd(n, m % n);
}

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  for (auto& val: a)
    std::cin >> val;
  std::vector<int> g1(N);
  g1[0] = a[0];
  std::vector<int> g2(N);
  g2.back() = a.back();
  for (int i = 1; i < N; ++i)
  {
    g1[i] = gcd(a[i], g1[i-1]);
  }
  for (int i = N - 2; 0 <= i; --i)
  {
    g2[i] = gcd(a[i], g2[i+1]);
  }
  int ans = std::max(g2[1], g1[N - 2]);
  for (int i = 1; i < N - 1; ++i)
  {
    int tmp = gcd(g1[i-1], g2[i+1]);
    ans = std::max(tmp, ans);
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1408
H, W = map(int, input().split())
L = [input() for _ in range(H)]
 
inf = 10**9
dp = [[inf] * W for _ in range(H)]
 
#[0][0]を埋める
if (L[0][0] == '.'):
    dp[0][0] = 0
else:
    dp[0][0] = 1
 
for i in range(H):
    for j in range(W):
 
        #[0][0]の時は無視
        if (i == 0 and j == 0):
            continue
        #→の場合。一個前のマス。
        a = dp[i][j - 1]
        #↓の場合。一個前のマス。
        b = dp[i - 1][j]
 
        #.から#に移動するときだけ操作が(1回)必要
        if (L[i][j - 1] == "." and L[i][j] == "#"):
            a += 1
        if (L[i - 1][j] == '.' and L[i][j] == '#'):
            b += 1
 
        # min(dp[i][j],a,b)でもいいが結局問題になるのはa,bの比較だけでは？
        dp[i][j] = min(a, b)
 
print(dp[-1][-1])

Measured memory_bytes: 9136
n = int(input())
r = []
for _ in range(n):
    r.append(int(input()))

maxv = -float("inf")
minv = r[0]

for i in range(1, n):
    maxv = max(maxv, r[i] - minv)
    minv = min(minv, r[i])

print(maxv)


Measured memory_bytes: 13592
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int N;

	cin >> N;

	vector<vector<int>> A(2, vector<int>(N));
	for (int i = 0; i < N; i++)	cin >> A[0][i];
	for (int i = 0; i < N; i++)	cin >> A[1][i];

	vector<vector<int>> DP(2, vector<int>(N));
	DP[1][N - 1] = A[1][N - 1];
	DP[0][N - 1] = DP[1][N - 1] + A[0][N - 1];

	for (int i = N - 2; i >= 0; i--)
		DP[1][i] = DP[1][i + 1] + A[1][i];
	for (int i = N - 2; i >= 0; i--)
		DP[0][i] = max(DP[0][i + 1], DP[1][i]) + A[0][i];

	int ans = DP[0][0];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main() {
	string s; cin >> s;
	int a=0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'x') {
			a++;
		}
	}
	if (a >= 8) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   ll a, b, c, d;
   cin >> a >> b >> c >> d;
   ll ctr_a = a - 1 - ((a - 1) / c + (a - 1) / d - (a - 1) / (c * d / gcd(c, d)));
   ll ctr_b = b - (b / c + b / d - b / (c * d / gcd(c, d)));
   cout << ctr_b - ctr_a << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//クラスカル法
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 10000
#define vmax 10000
#define sentinel 2000000000
#define INF (1<<29)
constexpr long long int inf = 1000000000000;
constexpr long long int rinf = -(INT64_MAX);
static const int NIL=-1;

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

class UnionFind{

    vector<int> par;
    int groupcount;

public:
// UnionFind uf(n)でn要素のUF木uf
    UnionFind(int n=0){
        init(n);
    }

    //n要素で初期化
    void init(int n=0){
        par.resize(n);
        fill(par.begin(),par.end(),-1);
        groupcount=n;
        return;
    }

    //xが属する集合の根を求める
    int root(int x){
        if(par[x]<0){
            return x;
        }
        return par[x]=root(par[x]);
    }

    //xとyが同じ集合に属するかどうか調べる
    bool same(int x,int y){
        return root(x)==root(y);
    }

    //xが属する集合の大きさを求める
    int size(int x){                
        return -par[root(x)];
    }

    //xが属する集合とyが属する集合を繋ぐ
    //既に繋がっていたらfalseが返る
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y){
            return false;
        }
        if(par[y]<par[x]){ 
            swap(x,y);
        }
        par[x]+=par[y];     
        par[y]=x;
        --groupcount;
        return true;        
    }

    //UF内にある集合の個数を求める
    int size(void){
        return groupcount;
    }
};

class edge{
    public:
    int source,target,cost;
    edge(int source=0,int target=0,int cost=0):
    source(source),target(target),cost(cost) {}
    bool operator < (const edge &e) const{
        return cost < e.cost;
    }
};

int kruskal(int n,vector<edge> edges){
    int totalcost=0;
    sort(edges.begin(),edges.end());//コストが小さい順に辺をソートする

    UnionFind uf(n);              //unionfindの初期化

    for(auto e:edges){
        if(!uf.same(e.source,e.target)){
            //MST.push_back(e);
            totalcost+=e.cost;
            uf.unite(e.source,e.target);
        }
    }
    return totalcost;
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> p(n+1);
    rep(i,n){
        cin>>p[i+1];
    }
    UnionFind uf(n+1);
    int x,y;
    rep(i,m){
        cin>>x>>y;
        uf.unite(x,y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(uf.same(i,p[i])){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
ans = []


for i in range(n):
    m = list(map(int,input().split()))
    if m[0] == 0:
        ans.append(m[1])
    elif m[0] == 1:
        print(ans[m[1]])
    
    elif m[0] == 2:
        ans.pop()


Measured memory_bytes: 13364
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  vector<int> w(N+2);
  rep(i,N){
    cin >> v[i];
    w[v[i]] = i+1;
  }
  set<int> stl;
  set<int> str;
  ll ans = 0;
  perr(x,1,N+1){
    auto itl = stl.upper_bound(-w[x]);
    auto itr = str.upper_bound(w[x]);
    ll l1,l2,r1,r2;
    //自分より大きい一番近く
    if(itl == stl.end()) l1 = 0;
    else l1 = *itl;
    if(itr == str.end()) r1 = N+1;
    else r1 = *itr;

    //自分より大きい二番目に近く
    if(l1==0)l2 == 0;
    else{
      stl.erase(itl);
      itl = stl.upper_bound(-w[x]);
      if(itl == stl.end()) l2 = 0;
      else l2 = *itl;
      stl.insert(l1);
    }
    if(r1==N+1)r2 = N+1;
    else{
      str.erase(itr);
      itr = str.upper_bound(w[x]);
      if(itr == str.end()) r2 = N+1;
      else r2 = *itr;
      str.insert(r1);
    }
    stl.insert(-w[x]);
    str.insert(w[x]);

    l1=-l1;
    l2=-l2;
    if(l1 != 0) ans += x*(l1-l2)*(r1-w[x]);
    if(r1 != N+1) ans += x*(r2-r1)*(w[x]-l1);
    //cout << x SP -l2 SP -l1 SP r1 SP r2 SP ans << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 

int main(){
  int X,Y,Z,sum=0,count=1;
  cin >> X >> Y >> Z;
  sum=Y+Z*2;
  while(sum<=X){
    sum+=Y+Z;
    count+=1;
  }
  cout << count-1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int N,L;
	cin>>N>>L;
	vector<int> a(N);

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

	sort(a.begin(),a.end());

	int min = 500;

	for(int i=0; i<N; i++)
	{
		if(abs(a[i]) <= abs(min))
		{
			min = a[i];
		}
	}

	int result = accumulate(a.begin(),a.end(),0) - min;
	cout<<result<<endl;

	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


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

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  // ll a, b, c; cin >> a >> b >> c;
  string s, t; cin >> s >> t;
  // vector<ll> a(N); rep(i, N) cin >> a[i];

  string ans = "EQUAL";
  if(s.size() == t.size()) {
    rep(i, s.size()) {
      if(s[i] ==  t[i]) continue;
      if(s[i] > t[i]) ans = "GREATER";
      else if(s[i] < t[i]) ans = "LESS";
      break;
    }
  } else {
    if(s.size() > t.size()) ans = "GREATER";
    else ans = "LESS";
  }
  cout << ans << endl;
  // A>B のときGREATER、A<B のときLESS、A=B のときEQUAL

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 256
n = int(input())
_n = n

prime = []
for i in range(2, int(n**0.5)+1):
    while n%i == 0:
        prime.append(i)
        n /= i

if len(prime) == 0 or n != 1:
    prime.append(int(n))

print(str(_n) + ":", *prime)


Measured memory_bytes: 5636
#include <stdio.h>

int main(void)
{
	int i=0, ch,a[10] = {0};

	while((ch = getchar()) != EOF){
		a[i] = ch - '0';
		i++;
	}
	int count = i-1, min = 900;

	for(i=0; i<count-2; i++){
		int num = a[i] * 100 + a[i+1] * 10 + a[i+2];
		int a = (753 > num) ? 753-num : num-753;
		if(min > a){
			min = a;
		}
	}
	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<cstdio>
using namespace std;



int main()
{
    deque<int> ans;
    int n;
    scanf("%d",&n);
    for(int i = 1; i<=n; i++)
    {
        int num;
        scanf("%d",&num);
        if(i&1)
            ans.push_front(num);
        else
            ans.push_back(num);
    }
    int i = 0;
    if(n&1)
    {
        while(i<n-1)
        {
            printf("%d ",ans.front());
            ans.pop_front();
            i++;
        }
        printf("%d\n",ans.front());
    }
    else
    {
        while(i<n-1)
        {
            printf("%d ",ans.back());
            ans.pop_back();
            i++;
        }
        printf("%d\n",ans.back());
    }
    return 0;
}


Measured memory_bytes: 2944
import java.util.*;
public class Main {
	static int hantei(int n){
		for(int s=n;s>=13;s--){
			if(prime[s]&&prime[s-2]&&prime[s-6]&&prime[s-8])return s;
		}
		return 0;
	}
	static boolean prime[] = new boolean[10000001];
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		for(int i=0;i<prime.length;i++)prime[i]=true;
		prime[0]=false;prime[1]=false;
		for(int s=0;s<prime.length;s++){
			if(prime[s])for(int i=s*2;i<prime.length;i+=s){
				prime[i]=false;
			}
		}
		while(in.hasNext()){
			int n=in.nextInt();
			if(n==0)return;
			System.out.println(hantei(n));
		}
	}
}

Measured memory_bytes: 35096
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>

using namespace std;

using ll = long long;
using vl = vector<long long>;
using vi = vector<int>;
using vvl = vector<vl>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

int main()
{
    ll n, W;
    cin >> n >> W;
    vl w(n), v(n);
    for (ll i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    vl dp(W + 1, 0), dpt(W + 1, 0);
    for (int i = 0; i < n; i++)
    {
        for (int we = 1; we < W + 1; we++)
            dpt[we] = max(dp[we], (we - w[i] >= 0 ? dp[we - w[i]] + v[i] : 0));
        dp = vl(dpt.begin(), dpt.end());
    }
    ll res = 0;
    for (int i = 1; i < W + 1; i++)
        res = max(res, dp[i]);
    cout << res;
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int h = S / (60 * 60);
        int m = (S - (h * 60 * 60)) / 60;
        int s = S - h*60*60 - m*60;
        System.out.println(h + ":" + m + ":" + s);
    }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<vector<pii>> shogen(n);
    REP(i,n){
        int32 a;
        cin >> a;
        REP(j,a){
            int32 x,y;
            cin >> x >> y;
            x--;
            // cout << x << " " << y << endl;
            shogen[i].pb(pii(x,y));
        }
    }
    // REP(i,n){
    //     for(pii p : shogen[i]){
    //         cout << p.first << " ";
    //     }
    //     cout << endl;
    // }
    int32 ans = 0;
    for(int32 mask = 0; mask < (1 << n); mask++){
        bool flg = true;
        REP(i,n){
            if((mask & (1 << i))){
                for(pii p : shogen[i]){
                    int32 x,y;
                    tie(x,y) = p;
                    // if((mask & (1 << x)) != y){
                    //     cout << i << " " << x << endl;
                    //     flg = false;
                    //     break;
                    // }
                    if(mask & (1 << x)){
                        if(y == 0){
                            flg = false;
                            break;
                        }
                    }else{
                        if(y == 1){
                            flg = false;
                            break;
                        }
                    }
                }
            }
        }
        // cout << bitset<16>(mask) << " " << flg << endl;
        // if(flg)ans++;
        if(flg)
            ans = max<int64>(ans, bitset<20>(mask).count());
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int L,R,l,r,i,j,min,temp;
  
  //L,Rを読み込み
  scanf("%d %d",&L,&R);
  
  l=L%2019;
  r=R%2019;
  min=2018;
  
  if(R-L>=2018){min=0;}
  
  
  for(i=l; i<r; i++){
  	for(j=i+1; j<=r; j++){
      temp=(i*j)%2019;
      if(min>=temp){min=temp;}
    }  
  }
  
  printf("%d\n",min);
  
  return(0);
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){
	int a,b,sum;
	scanf("%d%d",&a,&b);
	if(b>=0&&b<10){
		sum=10*a+b;
		}
	else if(b>=10&&b<100){
		sum=100*a+b;
		}
	else if(b>=100){
		sum=1000*a+b;
		}
	int i,count;
	for(i=0;i<318;i++){
		if(sum==i*i){
			count++;
			}
		}
	if(count>0){
		printf("Yes");
		}
	else{
		printf("No");
		}
	return 0;
}

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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second
 
Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    bool check = true;
    for (Int i = 0; i < n; i++) {
        check = check and (a[i] == i);
    }
    if (check) {
        dump(3);
        return 0;
    }
    Int res = 1;
    vector<Int> b(n, 0);
    for (Int i = 0; i < n; i++) {
        if (a[i] > 0) {
            if (b[a[i] - 1] == 0) {
                dump(0);
                return 0;
            }
            res *= (b[a[i] - 1] - b[a[i]]); 
            res %= mod;
        }
        b[a[i]]++;
        if (b[a[i]] > 3) {
            dump(0);
            return 0;
        }
    }
    dump((res * 6) % mod);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
// in-short-use macros
 
#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010
 
//main function here
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// freopen("C:/Users/saura/Desktop/cp/input.txt", "r", stdin);
	// freopen("C:/Users/saura/Desktop/cp/output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll m = a[0],ans=0;
	for(int i=1;i<n;i++)
	{
		if(m>a[i])
			ans+=m-a[i];
		else
			m = a[i];
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 5164
#include<cstdio>
#define ll long long
using namespace std;
int n;
char s[100],A[2][100];
ll f[100][100];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	ll ans=0;
	for (int i=0;i<(1<<n);i++)
	{
		int cnt0=0,cnt1=0;
		for (int j=1;j<=n;j++)
			if (!(i&(1<<j-1))) A[0][++cnt0]=s[j];
		for (int j=1;j<=n;j++)
			if (i&(1<<j-1)) A[1][++cnt1]=s[j];
		f[0][0]=1;
		for (int j=1;j<=n;j++)
			for (int k=0;k<=cnt0;k++)
			{
				f[j][k]=0;
				if (k!=0&&s[n+j]==A[0][cnt0-k+1])
					f[j][k]+=f[j-1][k-1];
				if (j!=k&&s[n+j]==A[1][cnt1-(j-k)+1])
					f[j][k]+=f[j-1][k];
			}
		ans+=f[n][cnt0];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    a5 = 0
    a7=0

    for i in a:
        if i == 5:
            a5 +=1
        if i ==7:
            a7 +=1

    if a5==2 and a7 ==1:
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
bool f(int n) {
    for (int i=1; i*i<=n; i++) {
        if (i*i==n) return true;
    }
    return false;
}
int a[50][50];
int n,d;
int main() {
    scanf("%d %d",&n,&d);
    for (int i=0; i<n; i++) {
        for (int j=0; j<d; j++) {
            scanf("%d",&a[i][j]);
        }
    }
    int cnt=0;
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<n; j++) {
            int sum = 0;
            for (int k=0; k<d; k++) {
                sum += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            if (f(sum)) cnt++;
        }
    }
    printf("%d",cnt);
}


Measured memory_bytes: 256