akhauriyash/Code-Regression huggingface dataset:
// D - Wizard in Maze
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

pair<int, int> dhw[] = { // <h, w>
        { 1, 0},
{ 0,-1},        { 0, 1},
        {-1, 0},
{ 2,-2},{ 2,-1},{ 2, 0},{ 2, 1},{ 2, 2},
{ 1,-2},{ 1,-1},        { 1, 1},{ 1, 2},
{ 0,-2},                        { 0, 2},
{-1,-2},{-1,-1},        {-1, 1},{-1, 2},
{-2,-2},{-2,-1},{-2, 0},{-2, 1},{-2, 2}
};

int main(){
	int H, W; cin>>H>>W;
	int C[2],D[2]; cin>>C[0]>>C[1]>>D[0]>>D[1];
	C[0]--, C[1]--, D[0]--, D[1]--;
	string S[H]; rp(i, 0, H) cin>>S[i];

	vvi vis(H, vi(W, -1));
	deque<tuple<int, int, int>> dq; // <h, w, gid>
	dq.push_back({C[0], C[1], 0});
	while(dq.size()){
		int h, w, gid; tie(h, w, gid) = dq.front(); dq.pop_front();
		if(h < 0 || H <= h || w < 0 || W <= w) continue;
		if(vis[h][w] >= 0 || S[h][w] == '#') continue;
		vis[h][w] = gid;

		rp(i, 0, 4){
			int nx_h = h + dhw[i].first, nx_w = w + dhw[i].second;
			dq.push_front({nx_h, nx_w, gid});
		}
		rp(i, 4, 24){
			int nx_h = h + dhw[i].first, nx_w = w + dhw[i].second;
			dq.push_back({nx_h, nx_w, gid+1});
		}

	}

	cout<< vis[D[0]][D[1]] <<endl;
}


Measured memory_bytes: 11760
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

vector<vin> g;

int dist_f[110000];
int dist_s[110000];

void dfs_f(int now){
 for(auto v:g[now]){
  if(dist_f[v]!=inf)continue;
   dist_f[v]=dist_f[now]+1;
   dfs_f(v);
 }
  return;
}
void dfs_s(int now){
 for(auto v:g[now]){
  if(dist_s[v]!=inf)continue;
   dist_s[v]=dist_s[now]+1;
   dfs_s(v);
 }
  return;
}

int main(){cout<<fixed<<setprecision(20);
           int n;
           cin>>n;
           g.resize(n);
           int a,b;
           rep(i,0,n-1){
            cin>>a>>b;
             a--;
             b--;
             g[a].pb(b);
             g[b].pb(a);
           }
           rep(i,0,n){
            dist_f[i]=inf;
            dist_s[i]=inf;
           }
           dist_f[0]=0;
           dist_s[n-1]=0;
           dfs_f(0);
           dfs_s(n-1);
           int f=0,s=0;
           rep(i,0,n){
            if(dist_s[i]<dist_f[i])s++;
            else f++;
           }
           if(f<=s){
             cout<<"Snuke"<<endl;
           }
           else{
             cout<<"Fennec"<<endl;
           }
          }

Measured memory_bytes: 14020
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

int MOD = pow(10, 9) + 7;

int kaijou(int n){
    if(n==0) return 1;
    else{
        return ((n%MOD)*(kaijou(n-1)%MOD))%MOD;
    }
}


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

    int ans=0;
    for(int i=1;i<=n;i++){
        if(i%2==1){
            if(a[i]%2==1) ans++;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3588
var
	N,K,i:Longint;
	inv:Array[1..2002]of Longint;
	B,R,M:int64;
begin
	read(N,K);
	inv[1]:=1;
	M:=1000000007;
	for i:=2 to K+2 do begin
		inv[i]:=M-M div i*inv[M mod i] mod M;
	end;
	B:=1;
	R:=N-K+1;
	for i:=0 to K-1 do begin
		writeln(B*R mod M);
		B:=B*(K-i-1)mod M*inv[i+1]mod M;
		R:=R*(N-K-i)mod M*inv[i+2]mod M;
	end;
end.


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[1000],b[1000];
int main()
{
    int c,d,e,f,i,k,l;
    cin>>c;
    cin>>d>>e;
    for(i=d; i<=e; i++)
    {
        if(i%c==0)
        {
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 2010*2010;
const int INF = 2147483600;

int N,M; 
#define pii pair<int,int>
#define fr first
#define sc second
#define mp make_pair 
int Node[MAXN<<1],Next[MAXN<<1],Root[MAXN+1],cnt; bool Ers[MAXN+1],Rev[MAXN+1];
pii Es[MAXN+1]; int top;
#define pb push_back
inline void insert(int u,int v){ Node[++cnt]=v; Next[cnt]=Root[u]; Root[u]=cnt; }
vector<pii > S[MAXN+1];
int fa[MAXN+1],Nod[MAXN+1],tim;
int dep[MAXN+1]; int P[2][MAXN+1];
inline int LCA(int u,int v){
	if(dep[u]<dep[v]) swap(u,v);
	while(dep[u]>dep[v]) u=fa[u];
	while(u!=v) u=fa[u],v=fa[v]; return u;
}
inline void dfs(int k,int Fa){
	dep[k]=dep[Fa]+1;
	for(int x=Root[k];x;x=Next[x]){
		int v=Node[x]; if(v==Fa) continue;
		dfs(v,k);
	} ++tim; fa[k]=Fa; Nod[tim]=k; 
} int id; int lnk[MAXN+1];
inline void solve(int nwid){
	int k=Nod[nwid]; top=0;
	for(int i=0,sz=S[k].size();i<sz;i++){ pii n=S[k][i]; if(Ers[n.sc]) continue; if(P[n.fr^1][n.sc]==k) Rev[n.sc]=0,Ers[n.sc]=n.fr; else Es[++top]=n; }
	S[k].clear(); for(int i=1;i<=top;i++) S[k].pb(Es[i]); pii x,y; int Ad=-1;
	if(S[k].size()>=2){
		int sz=S[k].size()-1;
		x=S[k][sz],y=S[k][sz-1];
		S[k].pop_back(); S[k].pop_back();
		Ad=++id; P[0][id]=P[x.fr^1][x.sc],P[1][id]=P[y.fr^1][y.sc];
		Ers[x.sc]=Ers[y.sc]=1;
		//cout<<"Ad:"<<P[0][id]<<" "<<P[1][id]<<":"<<x.sc<<" "<<y.sc<<" "<<k<<endl;
		S[P[0][id]].pb(mp(0,id));
		S[P[1][id]].pb(mp(1,id));
	} for(int i=0,sz=S[k].size();i<sz;i++) {
		++id; pii n=S[k][i];
		P[n.fr^1][id]=P[n.fr^1][n.sc];
		P[n.fr][id]=fa[k]; Ers[n.sc]=1;
		S[P[0][id]].pb(mp(0,id));
		S[P[1][id]].pb(mp(1,id));
		lnk[n.sc]=id;
	}
	if(nwid==N) return ; solve(nwid+1); 
	if(Ad!=-1){
		if(Rev[Ad]) swap(x,y);
		Rev[x.sc]=x.fr^1; Ers[x.sc]=1;
		Rev[y.sc]=y.fr; Ers[y.sc]=1;
	} for(int i=0,sz=S[k].size();i<sz;i++) {
		pii n=S[k][i]; Rev[n.sc]=Rev[lnk[n.sc]];
	} return ;
} int ans=0; int fx[MAXN+1];
inline void dfsans(int k,int Fa){
	for(int x=Root[k];x;x=Next[x]){
		int v=Node[x]; if(v==Fa) continue;
		dfsans(v,k); ans+=min(fx[v],2); fx[k]+=fx[v];
	}
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),M=read();
	for(int i=1;i<N;i++){
		int u=read(),v=read();
		insert(u,v); insert(v,u);
	} dfs(1,0); 
	for(int i=1;i<=M;i++){
		int u=read(),v=read();
		fx[u]++; fx[v]++; int p=LCA(u,v);
		fx[p]-=2;
		P[0][i]=u; P[1][i]=v;
		S[u].pb(mp(0,i));
		S[v].pb(mp(1,i));
	} id=M; dfsans(1,0); printf("%d\n",ans); solve(1);
	for(int i=1;i<=M;i++){
		if(Rev[i]) swap(P[0][i],P[1][i]);
		printf("%d %d\n",P[0][i],P[1][i]);
	}
	return 0;
}

Measured memory_bytes: 108920
#include <stdio.h>

int main(void){
    int n = 0;
    char s[3];
    scanf("%s", s);
    for (int i = 0; i < 3; i++){
        if (s[i] == '1'){
            n += 1;
        }
    }
    printf("%i\n", n);
    return 0;
}

Measured memory_bytes: 128
from collections import deque
import heapq
n, m = map(int, input().split())
jobs = [None]*n
q = []
heapq.heapify(q)
day = 0
ans = 0

for i in range(n):
    jobs[i] = tuple(map(int, input().split()))
jobs.sort(key = lambda x:x[1], reverse=True)
jobs.sort(key = lambda x:x[0])
jobs = deque(jobs)

for i in range(m):
    while True:
        if  not len(jobs) == 0:
            j = jobs.popleft()
            if not j[0] == i+1:
                jobs.appendleft(j)
                break
            else:
                heapq.heappush(q, -j[1])
        else:
            break
    if q:
        ans -= heapq.heappop(q)
print(ans)

Measured memory_bytes: 18404
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        Dice dice1 = createDice(), dice2 = createDice();
        System.out.println(dice1.equals(dice2) ? "Yes" : "No");
    }
    
    private static Dice createDice() {
        int[] num = new int[6];
        for(int i = 0; i < 6; i++) {
            num[i] = scn.nextInt();
        }
        return new Dice(num);
    }
}

class Dice {
    private int[] num_;
    public static final int
      TOP = 0, SOUTH = 1, EAST = 2,
      WEST = 3, NORTH = 4, BOTTOM = 5;
    
    public Dice(int... ary) {
        int[] num = new int[6];
        for(int i = 0; i < 6; i++) {
            num[i] = ary[i];
        }
        num_ = num;
    }
    
    public int show(int side) {
        return num_[side];
    }
    
    public int[] showAll() {
        return num_;
    }
    
    @Override
    public boolean equals(Object obj) {
        boolean rslt = false;
        Dice dice = (Dice)obj;
        String str = "-RRRNRRRNRRRSRRRSRRRNRRR";
        for(char elm : str.toCharArray()) {
            move(elm);
            if(Arrays.equals(showAll(), dice.showAll())) {
                rslt = true;
                break;
            }
        }
        return rslt;
    }
    
    public void move(String str) {
        char[] ary = str.toCharArray();
        for(char elm : ary) {
            move(elm);
        }
    }
    
    public void move(char dir) {
        if(dir == 'S') {
            toSouth();
        } else if(dir == 'E') {
            toEast();
        } else if(dir == 'W') {
            toWest();
        } else if(dir == 'N') {
            toNorth();
        } else if(dir == 'R') {
            toRight();
        } else if(dir == 'L') {
            toLeft();
        }
    }
    
    private void toSouth() {
        int tmp      = num_[TOP];
        num_[TOP]    = num_[NORTH];
        num_[NORTH]  = num_[BOTTOM];
        num_[BOTTOM] = num_[SOUTH];
        num_[SOUTH]  = tmp;
    }
    
    private void toEast() {
        int tmp      = num_[TOP];
        num_[TOP]    = num_[WEST];
        num_[WEST]   = num_[BOTTOM];
        num_[BOTTOM] = num_[EAST];
        num_[EAST]   = tmp;
    }
    
    private void toWest() {
        int tmp      = num_[TOP];
        num_[TOP]    = num_[EAST];
        num_[EAST]   = num_[BOTTOM];
        num_[BOTTOM] = num_[WEST];
        num_[WEST]   = tmp;
    }
    
    private void toNorth() {
        int tmp      = num_[TOP];
        num_[TOP]    = num_[SOUTH];
        num_[SOUTH]  = num_[BOTTOM];
        num_[BOTTOM] = num_[NORTH];
        num_[NORTH]  = tmp;
    }
    
    private void toRight() {
        int tmp      = num_[SOUTH];
        num_[SOUTH]  = num_[WEST];
        num_[WEST]   = num_[NORTH];
        num_[NORTH]  = num_[EAST];
        num_[EAST]   = tmp;
    }
    
    private void toLeft() {
        int tmp      = num_[SOUTH];
        num_[SOUTH]  = num_[EAST];
        num_[EAST]   = num_[NORTH];
        num_[NORTH]  = num_[WEST];
        num_[WEST]   = tmp;
    }
}

Measured memory_bytes: 26412
void main() {
	auto N = ri;
	auto S = rs;
	if(S[0..N/2] == S[N/2..$]) writeln("Yes");
	else writeln("No");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=a/d;
  int y=c/b;
  if(a%d!=0) x++;
  if(c%b!=0) y++;
  cout<<(x>=y?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define pb               push_back
#define all(x)           (x).begin(), (x).end()

typedef vector <int> vi;

const int N = 300010;
int nxt = 0;
int root[N];

struct Node{
    int ls,rs,val, id = 0;
}node[N*50];

void update(int &n,int pre,int b,int e,int pos, int id) {
    n = ++nxt;
    node[n] = node[pre];
    if(b==e && b==pos) {
        node[n].val++;
        node[n].id = max(node[n].id, id);
        node[n].ls = node[n].rs = 0;
        return;
    }
    int mid = (b+e)/2;
    if(pos<= mid) update(node[n].ls, node[pre].ls, b, mid,pos, id);
    else update(node[n].rs, node[pre].rs, mid+1,e,pos, id);
    node[n].val = node[node[n].ls].val + node[node[n].rs].val;
    node[n].id = max(node[node[n].ls].id,  node[node[n].rs].id);
}
int q;
vi A;

int query_sum(int root, int b, int e, int l, int r){

    if (l > r) return 0;
    if (l > e || b > r) return 0;
    if (b == l && r == e) {
        return node[root].val;
    }
    int mid = (b+e)/2;
    return query_sum(node[root].ls, b, mid, l, min(r, mid)) + query_sum(node[root].rs, mid+1, e, max(l, mid+1), r);
}

int query(int root, int b, int e, int l, int r){
    if (l > r) return 0;
    if (l > e || b > r) return 0;
    if (b == l && r == e) return node[root].id;
    int mid = (b+e)/2;
    return max(query(node[root].ls, b, mid, l, min(r, mid)), query(node[root].rs, mid+1, e, max(l, mid+1), r));
}

int main() {
    int n;
    cin >> n >> q;
    int K = 300001;
    A.resize(K);
    for (int j = 0; j < n; ++j) {
        cin >> A[j];

    }
    vi ans(K, 1);
    int res = 1;
    for (int k = 1; k <= n; ++k) update(root[k], root[k-1], 0, K-1, A[k-1], k-1); // 0 -> is the initial empty segment tree

    for (int i = 1; i <= n; ++i) {
        int sum1 = query_sum(root[i-1], 0, K-1, max(A[i-1]-q, 0), A[i-1]);
        int sum2 = query_sum(root[i-1], 0, K-1, A[i-1], min(K-1, A[i-1]+q));
        if (sum1){
            int ind = query(root[i-1], 0, K-1, max(A[i-1]-q, 0), A[i-1]);
            ans[i-1] = 1 + ans[ind];
        }if (sum2){
            int ind = query(root[i-1], 0, K-1, A[i-1], min(K-1, A[i-1]+q));
            ans[i-1] = max(ans[i-1], 1 + ans[ind]);
        }

        res = max(res, ans[i-1]);
    }
    cout << res << "\n";
}

Measured memory_bytes: 241052
import math
n, d = input().split()
xi, yi = 0, 0
cnt = 0
for i in range(int(n)):
    xi, yi = input().split()
    xi, yi = float(xi), float(yi)
    dist = math.sqrt(pow(xi, 2) + pow(yi, 2))
    if dist <= float(d):
      cnt += 1
print(cnt)

Measured memory_bytes: 9308
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef int i32;
typedef long long i64;
typedef vector<int> vec32;
typedef vector<long long> vec64;
template<class T>inline bool Min(T& x,T y){
  if(x > y){
    x = y;
    return true;
  }
  return false;
}
i64 calc(i32 N, string S){
  N = S.size();
  vec32 WhiteSum(N+1,0);
  vec32 BlackSum(N+1,0);
  for(i32 i = 0; i < N; i++){
    if(S[i] == '.'){
      WhiteSum[i+1] = WhiteSum[i] + 1;
    } else {
      WhiteSum[i+1] = WhiteSum[i] + 0;
    }
    if(S[i] == '#'){
      BlackSum[i+1] = BlackSum[i] + 1;
    } else {
      BlackSum[i+1] = BlackSum[i] + 0;
    }
  }

  i64 ans = 1LL<<60;
  for(i32 j = 0; j <= N; j++){
    i64 count = 0;
    count += BlackSum[j] - BlackSum[0];
    count += WhiteSum[N] - WhiteSum[j];
    Min(ans,count);
  }
  return ans;
}
int main(){
  i32 N;
  string S;
  cin >> N >> S;
  cout << calc(N,S) << endl;
  return 0;
}

Measured memory_bytes: 2308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] args) throws IOException{
		
		BufferedReader buf= new BufferedReader(new InputStreamReader(System.in));
		String str =buf.readLine(); //入力する桁数
		int count=Integer.parseInt(str);
		
		int[] a=new int[count];
		int[] b=new int[count];
		int[] c=new int[count];
		
		for(int i=0;i<count;i++){
			str=buf.readLine();
			a[i]=Integer.parseInt(str.split(" ")[0]);
			b[i]=Integer.parseInt(str.split(" ")[1]);
			c[i]=Integer.parseInt(str.split(" ")[2]);
		}
		buf.close();
		for(int i=0;i<count;i++){
			if(
				(a[i]*a[i]+b[i]*b[i]==c[i]*c[i])|| /*直角三角形の成立条件（ピタゴラスの定理、a＾2 + b＾2 = c＾2）*/
				(a[i]*a[i]+c[i]*c[i]==b[i]*b[i])||
				(b[i]*b[i]+c[i]*c[i]==a[i]*a[i])
				){
				System.out.println("YES");
			}else{
					System.out.println("NO");
			}
		}
	}
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main(){ _

	int n; cin >> n;
	vector<ll> v(n), pref(n);
	for(ll& i : v) cin >> i;

	pref[0] = v[0];
	for(int i=1; i<n; i++) pref[i] = pref[i-1]+v[i];

	auto query = [&] (int l, int r) {return pref[r] - (l ? pref[l-1] : 0);};

	vector<vector<ll>> memo(n+1, vector<ll>(n)); // sz, start

	for(int sz = 2; sz <= n; sz++) {
		for(int i=0; i<=n-sz; i++) {
			memo[sz][i] = LINF;
			for(int sz2 = 1; sz2 < sz; sz2++)
				memo[sz][i] = min(memo[sz][i], memo[sz2][i] + memo[sz-sz2][i+sz2]);

			memo[sz][i] += query(i, i+sz-1);
		}
	}

	cout << memo[n][0] << endl;

	return 0;
}


Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
#define EN cout<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 ll dp[2000][2000];

//距離がない　サイクルがあるとDagでない
//トコロジカルソート


class DAG
{
    int n;
    vector<vector<int>> adj;
    vector<int> visited;
    vector<int> dp;
    void dfs(int v)
    {
        if (visited[v] == 2)
        {
            is_acyclic = false;
            return;
        }
        else if (!visited[v])
        {
            visited[v] = 2;
            for (int s : adj[v])
            {
                dfs(s);
            }
            visited[v] = 1;
            sorted.push_back(v);
        }
    }

public:
    vector<int> sorted;
    DAG(int n) : n(n), adj(n), visited(n), dp(n, 0) {}
    bool is_acyclic = true;
    int longest_path = 0;

    //add directed link node a to node b
    void add_arc(int a, int b)
    {
        assert(0 <= a && a < n && 0 <= b && b < n);
        adj[a].push_back(b);
    }

    void tsort()
    {
        for (int i = 0; i < n; i++)
        {
            if (!visited[i])
                dfs(i);
        }
        reverse(sorted.begin(), sorted.end());
    }
    void build()
    {
        for (auto i : sorted)
        {
            for (auto j : adj[i])
            {
                dp[j] = max(dp[j], dp[i] + 1);
                longest_path = max(longest_path, dp[j]);
            }
        }
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    DAG dag(n+10);
    rep(i,m){
        ll x,y;
        cin>>x>>y;

        dag.add_arc(x,y);
    }
    dag.tsort();
    dag.build();
    cout<<dag.longest_path<<endl;

}


Measured memory_bytes: 12032
while True:
    n,k=map(int,input().split())
    if n == 0 and k == 0:break
    a=[int(input())for _ in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))
    



Measured memory_bytes: 11704
#include<iostream>
using namespace std;
int main(){
	int t[55];
	int n,m;
	int a,b,c;
	int i,j,k;
	int s=0;
	cin>>n>>m>>c;
	for(i=0;i<m;i++){
		cin>>t[i];
	}
	for(i=0;i<n;i++){
		a=0;
		for(j=0;j<m;j++){
			cin>>b;
			a+=b*t[j];
		}
		a+=c;
		if(a>0)s++;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		while (true)
		{
			int n = sc.nextInt(),
				m = sc.nextInt();
			if (n == 0 && m == 0)
				break;
			
			int taro[] = new int[n];
			int taroTotal = 0;
			for (int i = 0; i < n; i++)
			{
				taro[i] = sc.nextInt();
				taroTotal += taro[i];
			}
			int hanako[] = new int[m];
			int hanakoTotal = 0;
			for (int i = 0; i < m; i++)
			{
				hanako[i] = sc.nextInt();
				hanakoTotal += hanako[i];
			}
			LOOP: {
				for (int i = 0; i < n; i++)
				{
					for (int j = 0; j < m; j++)
					{
						if (taroTotal - taro[i] + hanako[j] == hanakoTotal - hanako[j] + taro[i])
						{
							System.out.printf("%d %d\n", taro[i], hanako[j]);
							break LOOP;
						}
					}
				}
				System.out.println(-1);
			}
		}
	}
}

Measured memory_bytes: 0
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;
	int ans = 19000;
	for (int i = 0; i < s.size() - 2; i++) {
		int box = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i+2] - '0';
		ans = min(ans, abs(box - 753));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int num[111111];
int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  int p = 0;

  p = (int)s.find("AC", p);
  if (p != -1) p++;
  while (p != -1) {
    num[p] = 1;
    p = (int)s.find("AC", p);
    if (p != -1) p++;
    // cout << "p:" << p << endl;
  }
  for (int i = 1; i < n; i++) {
    num[i] += num[i - 1];
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    cout << num[r] - num[l] << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
int N;
int main ()
{
scanf("%d",&N);
int res=N;
for(int i=0;i<=N;i++) {
int cc =0;
int t=N-i; while(t>0)cc+=t%6,t/=6; t=i; while(t>0)cc+=t%9,t/=9; if(res>cc)res=cc;
} printf("%d\n",res);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
string S;

bool check() {
  cin >> S;
  N = S.size();
  rep(i, N) {
    if (i%2 == 0) {
      if (S[i] == 'L') return false;
    } else {
      if (S[i] == 'R') return false;
    }
  }
  return true;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  if (check()) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
dp = [0]*100
dp[0] = 1
dp[1] = 1

def fib(n):
    if dp[n]!=0:
        return dp[n]
    else:
        dp[n] = fib(n-1) + fib(n-2)
    return dp[n]
    
print(fib(int(input())))


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

typedef long long int int64;

#define POS(i,j) ((i)*(2*50*n+1)+(j)+50*n)

void run(void){
  int n,a;
  scanf("%d%d",&n,&a);
  int64 *dp=(int64 *)calloc(2*50*n+1,sizeof(int64));
  int now=0;
  dp[POS(0,0)]=1;
  int l,r;
  l=r=0;
  int i,j;
  for(i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    x-=a;
    int next=now^1;
    for(j=l;j<=r;j++) dp[POS(next,j)]=dp[POS(now,j)];
    for(j=l;j<=r;j++) dp[POS(next,j+x)]+=dp[POS(now,j)];
    if(x<0){
      l+=x;
    } else {
      r+=x;
    }
    now=next;
  }
  printf("%lld\n",dp[POS(now,0)]-1);
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+200;
typedef long long ll;
typedef pair<ll,ll> pii;
ll A,B,C,x[3];
ll cnt[3];
vector<pii> v;
bool cmp(pii aa,pii bb)
{
	return aa.first>bb.first;
}
int main()
{
	cin>>x[0]>>x[1]>>A>>B>>C;
	for(int i=0;i<A;i++){ll val;scanf("%lld",&val);v.push_back({val,0});}
	for(int i=0;i<B;i++){ll val;scanf("%lld",&val);v.push_back({val,1});}
	for(int i=0;i<C;i++){ll val;scanf("%lld",&val);v.push_back({val,2});}
    sort(v.begin(),v.end(),cmp);
    ll ans=0;
    for(auto q:v)
    {
    	if(q.second==2) 
    	{
    		cnt[2]++;ans+=q.first;
		}
		else if(cnt[q.second]<x[q.second]){
			cnt[q.second]++;ans+=q.first;
		}
		
		if(cnt[0]+cnt[1]+cnt[2]==x[0]+x[1])
		{
			printf("%lld\n",ans);
			return 0;
		}
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 10476
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    LL x;
    cin >> x;
    LL ans=0;
    ans += x/500 * 1000;
    x%=500;
    ans += x/5 * 5;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <ctype.h>
const int bufSize = 1e6;
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufSize, stdin), p1 == p2) ? EOF : *p1++;
}
inline void read(char *s)
{
    static char c;
    for (; !isalpha(c); c = nc());
    for (; isalpha(c); c = nc()) *s++ = c;
    *s = '\0';
}
template<typename T>
inline T read(T &r)
{
    static char c;
    static int flag;
    flag = 1, r = 0;
    for (c = nc(); !isdigit(c); c = nc()) if (c == '-') flag = -1;
    for (; isdigit(c); c = nc()) r = r * 10 + c - 48;
    return r *= flag;
}
int n,x,t;
int main()
{
    read(n),read(x),read(t);
    printf("%d\n",(n+x-1)/x*t);
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int dp[3010][3010][2];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < t; j++) {
            for(int k = 0; k < 2; k++) {
                if(j - a[i] >= 0) {
                    chmax(dp[i + 1][j][k], dp[i][j - a[i]][k] + b[i]);
                }
                chmax(dp[i + 1][j][k], dp[i][j][k]);
                // 最後に食べるとき
                if(k == 0) {
                    chmax(dp[i + 1][j][1], dp[i][j][k] + b[i]);
                }
            }
        }
    }

    int ans = 0;
    for(int j = 0; j < t; j++) {
        for(int k = 0; k < 2; k++) {
            chmax(ans, dp[n][j][k]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 70912
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	int N,K;
	scanf("%d %d",&N,&K); 
	int p[N];
	for(int i=0;i<N;i++){
		scanf("%d",&p[i]);
	}
	qsort(p,N,sizeof(int),compare_int);
	int answer = 0;
	for(int i=0;i<K;i++){
		answer += p[i];
	}
	printf("%d",answer);
	return 0;
}


Measured memory_bytes: 1748
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    int k;
    int z;
    int i=-1;
    
    scanf("%d%d",&n,&k);
    
    while(n!=0){
        z=n;
        n=n/k;
        i++;
    }
    
    if(z%k!=0)i++;
    
    
    printf("%d\n",i);
    
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAXN 200000

int a[MAXN],prefixMax[MAXN], suffixMax[MAXN];

int main(){
    int N;

    scanf("%d",&N);

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

    prefixMax[0] = a[0];
    suffixMax[N - 1] = a[N - 1];

    for(int i = 1;i < N;++i){
        prefixMax[i] = max(prefixMax[i - 1], a[i]);
        suffixMax[N - 1 - i] = max(suffixMax[N - i], a[N - 1 - i]);
    }

    for(int i = 0;i < N;++i){
        int best = 0;
        if(i > 0) best = max(best, prefixMax[i - 1]);
        if(i + 1 < N) best = max(best, suffixMax[i + 1]);
        printf("%d\n", best);
    }
}


Measured memory_bytes: 3840
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
  
typedef long long ll;
const int N = 100010;
const ll mod = 1e9 + 7;

ll a[N], b[N];

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    ll ans = 0, p = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
        b[i] = b[i - 1] + a[i];
        if (a[i] > 0) p += a[i];
    }
    for (int i = 1; i <= k; ++i) {
        if (a[i] > 0) p -= a[i];
    }
    for (int i = 1; i + k - 1 <= n; ++i) {
        ans = max(ans, p);
        ans = max(ans, b[i + k - 1] - b[i - 1] + p);
        if (a[i] > 0) p += a[i];
        if (a[i + k] > 0) p -= a[i + k];
    }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

template <int n>
struct UnionFind{
    UnionFind(){
        for(int i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x){
        if(x == par[x])return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y){return;}
        
        if(rank[x] > rank[y]){
            par[y] = x;
        }else{
            par[x] = y;
            if(rank[x] == rank[y]){rank[y]++;}
        }
    }
    int rank[n], par[n];
};

UnionFind<100100> uf;

int N, M;
int ps[100100], qs[100100];

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

    std::cin >> N >> M;

    for(int i=1;i<=N;++i){
        std::cin >> ps[i];
        qs[ps[i]] = i;
    }

    for(int i=0;i<M;++i){
        int x, y;
        std::cin >> x >> y;

        uf.unite(x, y);
    }

    int res = 0;
    for(int i=1;i<=N;++i){
        // std::cout << i << ", " << qs[i] << ", " << uf.same(i, qs[i]) << std::endl;
        if(uf.same(i, qs[i])){
            ++res;
        }
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <unordered_map>

int main() {
	int n;
	std::vector<int> p;
	
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		int num;
		std::cin >> num;
		p.push_back(num);
	}

	auto sorted = p;
	std::sort(sorted.begin(), sorted.end());
	
	int counter = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] != sorted[i])
		{
			++counter;
			if (counter > 2)
			{
				std::cout << "NO" << "\n";
				return 0;
			}	
		}		
	}
	std::cout << "YES" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> A(M);
  vector<int> B(M);
  
  for ( int i = 0; i < M; i++ ) {
    cin >> A.at(i) >> B.at(i);
  }
  
  vector<int> city(N);
  
  for ( int i = 0; i < M; i++ ) {
    city.at(A.at(i) - 1)++;
    city.at(B.at(i) - 1)++;
  }
  
  for ( int i = 0; i < N; i++ ) {
    cout << city.at(i) << endl;;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string N;
    cin >> N;
    int iN = stoi(N);
    
    int sum = 0;
    for (char c : N)
    {
        sum += c - '0';
    }

    string ans;
    if (iN % sum == 0)
    {
        ans = "Yes";
    }else
    {
        ans = "No";
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.

import java.util.*;

class Main
{
    public static void main(String[] args) 
    {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        ArrayList<Integer> v = new ArrayList<>(n);
        for (int i=0;i<n;i++){
            v.add(new Integer(scan.nextInt()));
        }
        ArrayList<Integer> w = new ArrayList<>(v);
        Collections.sort(v);        
        int med=v.get(n/2);
        for(int i=0;i<n;i++){
            if (w.get(i)<med){
                System.out.println(v.get(n/2));
            }else{
                System.out.println(v.get(n/2-1));
            }
        }
    }
}

// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase


Measured memory_bytes: 96588
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{
    int n;
    cin >> n;
    cout << 1110 - n << endl;

    return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x=> int.Parse(x)).ToArray();

            var answer = input[0] * 100 + input[1] * 10 + input[2];

            if (answer % 4 == 0) Console.WriteLine( "YES");
            else Console.WriteLine("NO");

        }

    }

}


Measured memory_bytes: 13396
M, D = map(int, input().split())
cnt = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        d1, d2 = divmod(d, 10)
        if d1 >= 2 and d2 >= 2 and d1 * d2 == m:
            cnt += 1
print(cnt)

Measured memory_bytes: 2940
// Biscuit_Generator
// https://atcoder.jp/contests/abc125/tasks/abc125_a
// date: 2020-08-15T19:20:35.753917

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(ll) a;i<(ll) b;i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _repd(i,n) repdi(i,0,n)
#define repdi(i,a,b) for(ll i=(ll) b-1;i>=(ll) a;i--)
#define repd(...) _overload3(__VA_ARGS__,repdi,_repd,)(__VA_ARGS__)

#define all(x) x.begin(),x.end()
#define SIZE(x) ((ll)(x).size())

#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define bit(n) (1LL<<(n))
#define UNIQUE(v) (v.erase( unique(v.begin(), v.end()), v.end() ))

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<typename T, typename ...Args>
void CIN(T& first, Args&... args) {
    ((cin >> first), ..., (cin >> args)); //C++17
}

template<char Sep, typename T, typename ...Args>
void COUNT_NL(const T& first, const Args&... args) {
    ((cout << first), ..., (cout << Sep << args)); //C++17
}

template<typename... Words>
void COUT(Words... words) {
    COUNT_NL<' '>(words...);
    cout << endl;
    return;
}

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange

int solve(void) {
    ll N;
    CIN(N);
    vector<int> v(N);
    rep(i,N) {
        CIN(v[i]);
    }

    sort(all(v));
//    UNIQUE(v);
//    reverse(all(v));
//    v.erase(std::unique(v.begin(), v.end()), v.end());
//    auto uv=v.erase( unique(v.begin(), v.end()), v.end() );
    N=SIZE(v);
    ll cnt=0;
//    rep(i,N) {
//        COUT(v[i]);
//    }
    rep(i,N) {
        rep(j,i+1,N) {
            rep(k,j+1,N) {
                if(v[k] < v[i] + v[j]
                   && v[i] != v[j]
                   && v[k] != v[j] ) {
                    cnt++;
//                    COUT(v[k],v[i],v[j]);
                }
            }
        }
    }
    COUT(cnt);

    return 0;
}

int main(void){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);

    solve();
    return 0;
}


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    N, Ma, Mb = map(int, input().split())
    A, B, C = [0] * N, [0] * N, [0] * N
    for i in range(N):
        A[i], B[i], C[i] = map(int, input().split())

    INF = 10**10  # INF+INFを計算してもオーバーフローしない範囲で大きく
    I, J, K = N, sum(A), sum(B)
    dp = [[[INF]*(K+1) for _ in range(J+1)] for _ in range(I+1)]
    dp[0][0][0] = 0
    for i in range(1, I+1):
        for j in range(J+1):
            for k in range(K+1):
                # i-1番目を選ぶ場合
                if j >= A[i-1] and k >= B[i-1]:
                    dp[i][j][k] = min(dp[i][j][k], dp[i-1]
                                      [j-A[i-1]][k-B[i-1]]+C[i-1])
                dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k])
    ans = INF
    for j in range(1,J+1):
        for k in range(1,K+1):
            if k*Ma == j*Mb and k*Ma!=0 and j*Mb!=0:
                ans = min(ans, dp[I][j][k])

    print(-1 if ans == INF else ans)


resolve()

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


void solve() {
    int N, M;
    cin >> N >> M;

    vi oks(N + 1, true);
    for (int i = 0; i < M; ++i) {
        int a;
        cin >> a;
        oks[a] = false;
    }

    vl dp(N + 1);
    dp[0] = 1;
    for (int now = 0; now < N; ++now) {
        for (int next = now + 1; next <= min(N, now + 2); ++next) {
            if (oks[next]) {
                dp[next] += dp[now];
                dp[next] %= MOD;
            }
        }
    }

    cout << dp[N] << "\n";
}


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

    solve();
    return 0;
}


Measured memory_bytes: 1408
import collections
while True:
    w,h = map(int,input().split())
    if w == h == 0:
        break
    else:
        ans = 1
        L = []
        q = collections.deque()
        for i in range(h):
            s = input()
            T = []
            for j in range(w):
                if s[j] == '@':
                    T.append(0)
                    q.append([i,j])
                else:
                    T.append(s[j])
            L.append(T)
        dy_dx = [[1,0],[0,1],[-1,0],[0,-1]]
        while len(q) > 0:
            cur = q.popleft()
            for i in range(4):
                y = cur[0]+dy_dx[i][0]
                x = cur[1]+dy_dx[i][1]
                if 0 <= x < w and 0 <= y < h:
                    if L[y][x] == '.':
                        L[y][x] = L[cur[0]][cur[1]]+1
                        ans += 1
                        q.append([y,x])
        print(ans)
            


Measured memory_bytes: 6008
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } //1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } 
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } //a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } //aaa,aab
//temmie_のsnippet

int main() {
	int n,c,k,t[100009];
	scanf("%d%d%d",&n,&c,&k);
	rep(i,n)scanf("%d",t+i);
	qsort(t,n,4,acs);

	int ans=0,psng=0,dep=-2e9;
	rep(i,n){
		if(psng==c||dep<t[i]){ans++;psng=1;dep=t[i]+k;}
		else psng++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 2304
#include<iostream>
#include<map>
#include<queue>
using namespace std;

int main() {    
    int N, K;
    cin >> N >> K;
    map<int, int> mp;
    priority_queue<int, vector<int>, greater<int>> que;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }

    for(auto p : mp) {
        que.push(p.second);
    }

    int ans = 0;
    for(int i = K; i < mp.size(); i++) {
        int n = que.top(); que.pop();
        ans += n;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10748
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] read = ReadLine().Split(' ');
//        int read_leng = read.Length;
//        int[] readR = new int[mochinum];
        long a = long.Parse(read[0]);
        long b = long.Parse(read[1]);
        long c = long.Parse(read[2]);
//        int d = int.Parse(read[3]);
        
        string ans = "NO";
        for(int i=1;i<=b;i++){
            if(a*i % b == c){
                ans = "YES";
            }
        }
        WriteLine(ans);
    }
}


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

int main(){
    int q;
    cin >> q;
    double a[q], b[q];
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < q; i++){
        double sq = sqrt(a[i]*b[i]);
        long long int sqn = sq;
        long long int r;
        if(sq - sqn == 0){
            if(a[i] == sqn){
                r = (sqn-1)*2;
                cout << r << endl;
            }
            else{
                r = (sqn-1)*2 - 1;
                cout << r << endl;
            }
        }
        else{
            long long int sqr = (a[i]*b[i])/sqn;
            if(sqn*sqr == a[i]*b[i]){
                sqr = sqr-1;
            }
            if(sqr == sqn) r = sqn*2-2;
            else r = (sqn)*2 - 1;
            cout << r << endl;
        }
    }
    return 0;
}

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

ll n;
pair<ll,ll> a[105];
bool b[105];
pair<ll,ll> c[105];
bool d[105];

int main(){
    cin >> n;
    for(ll i=0;i<n;i++){
        ll p,q;
        cin >> p >> q;
        a[i]=make_pair(p,q);
    }
    for(ll i=0;i<n;i++){
        ll p,q;
        cin >> p >> q;
        c[i]=make_pair(p,q);
    }
    for(ll i=0;i<n;i++){
        b[i]=false;
        d[i]=false;
    }
    sort(a,a+n);
    sort(c,c+n);
    for(ll i=0;i<n;i++){
        ll memo=-1;
        for(ll j=0;j<n;j++){
            if(c[i].first>a[j].first&&c[i].second>a[j].second&&b[j]==false){
                if(memo==-1) memo=j;
                else{
                    if(a[j].second>a[memo].second) memo=j;
                }
            }
        }
        d[i]=true;
        b[memo]=true;
    }
    ll count=0;
    for(ll i=0;i<n;i++) if(b[i]) count++;
    cout << count << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    vector<int> a = A;
    sort(all(A));
    rep(i, 0, N)
    {
        if (a[i] != A[N - 1])
        {
            cout << A[N - 1] << endl;
        }
        else
        {
            cout << A[N - 2] << endl;
        }
    }
}


Measured memory_bytes: 3200