akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
typedef pair<ll,ll> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

//union-find tree
//要素数nで初期化
//必要に応じて操作ができるように各操作を関数にしておく
//100010を設定しておく
vector<ll> par(100010,0);//親（一つ上のノード）を持つ
vector<ll> ran(100010,0);

void ini(ll x){
    for(ll i=0;i <= x;i++)
    {
        par.at(i)=i;
    }
}
//-----------↑初期化↑--------------

ll findroot(ll x){
    if(par.at(x)==x){
        return x;
    }else{
        return findroot(par.at(x));
    }
}//根を見つける

//-----------↑親を見つける↑---------------

bool same(ll x,ll y){
    return findroot(x)==findroot(y);
}

//-----------↑同じグループかどうか判定↑----------

void unite(ll x,ll y){
    x=findroot(x);
    y=findroot(y);
    if(x==y){
        return ;
    }//二要素の根が同じならおわり

    if(ran.at(x)<ran.at(y)){
        par.at(x)=y;
    }else if(ran.at(x)>ran.at(y)){
        par.at(y)=x;
    }else{
        par.at(x)=y;
        ran.at(y)++;//ランクの低い方の木の根を高い方の根につなげる
    }
}
//-----------↑二つの要素をつなげる↑------------

signed main(){
    ll n,m,ans=0;
    cin>>n>>m;
    ini(n+2);
    vector<ll> v(n+1,0);//1-index
    for(ll i=1;i < n+1;i++)
    {
        cin>>v.at(i);
    }
    for(ll i=0;i < m;i++)
    {
        ll x,y;
        cin>>x>>y;
        //cout<<par[x]<<"DEBUG"<<par[y]<<endl;
        unite(x,y);
        //cout<<par[x]<<"DEBUG"<<par[y]<<endl;
    }
    
    for(ll i=1;i < n+1;i++)
    {
        //cout<<par[v.at(i)]<<"DEBUG"<<par[i]<<endl;
        if(same(v.at(i),i)){//
            ans++;
        }
    }

    cout<<ans<<endl;
}
    

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
string c1,c2;
char x1[5000005],x2[5000005];
int fail[5000005];
int cou[5000005];
int main(){
	cin>>c1>>c2;
	string t1=c1;
	while(c1.size()<=(int)(t1.size()+c2.size())*2) c1+=t1;
	c1+=t1;
	int f=0;
	int n1=c1.size();
	int n2=c2.size();
	fail[0]=-1;
	for (int i=1,j=-1;i<=n2; fail[i++] = ++j)
		while (j>=0&&c2[j]!=c2[i-1]) j=fail[j];
	for (int i=0,j=0;i<n1;++i) {
		while(j>=0&&c2[j]!=c1[i]) j = fail[j];
		if(++j==n2) cou[i]=1;
	}
	for(int i=n2;i<n1;i++) if(cou[i])cou[i]+=cou[i-n2];
	int ma=0;
	for(int i=0;i<n1;i++){
		ma=max(ma,cou[i]);
	}
	if(ma>=n1/n2-2) cout<<-1;
	else cout<<ma;
}

Measured memory_bytes: 20688
from collections import Counter
while True:
    W, D = map(int, input().split())
    if not (W | D):
        break
    hw = [int(x) for x in input().split()]
    hd = [int(x) for x in input().split()]
    print(sum(hw) + sum(hd) - sum(k * v for k, v in (Counter(hw) & Counter(hd)).items()))

Measured memory_bytes: 7936
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){
}

int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> a(n+1);
    vector<int> b(n+1);
    a[0] = 1;
    a[1] = 1;
    rep(i,m){
        int q;
        cin >> q;
        b[q] = 1;
    }
    if(b[1]==1){
        a[1] = 0;
    }
    for(int i=2;i<n+1;i++){
        if(b[i]==0){
            a[i] = a[i-1] + a[i-2];
            a[i] %= 1000000007;
        }else{
            a[i] = 0;
        }
    }
    cout << a[n];
    return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
	return (a.first > b.first);
}
int main(){
	ll x,y,a,b,c;
	scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
	ll p[a],q[b],r[c];
	vector<pair<ll,ll>>v;
	for(ll i=0;i<a;i++){
		cin>>p[i];
		v.push_back({p[i],0});
	}
	for(ll i=0;i<b;i++){
		cin>>q[i];
		v.push_back({q[i],1});
	}
	for(ll i=0;i<c;i++){
		cin>>r[i];
		v.push_back({r[i],2});
	}
	sort(v.begin(),v.end(),sortinrev);
	ll va=0,vb=0,all=0,ans=0;
	for (ll i =0; i < a + b + c; ++i){
		if (all == x + y)
			break;
		if (v[i].second == 0){
			if (va < x){
				++va;
				ans += v[i].first;
				++all;
			}
		}
		if (v[i].second == 1){
			if (vb < y){
				++vb;
				ans += v[i].first;
				++all;
			}
		}
		if (v[i].second == 2){
			ans += v[i].first;
			++all;
		}
	}
	cout<<ans<<endl;

}


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



int main() {
  int w,h,n;
  cin >> w >>h >>n;
  int lx=0,rx=w,ly=0,ry=h;
  rep(i,n){
    int x,y,a;
    cin >>x >>y >>a;
    if(a==1){lx=max(lx,x);}
    if(a==2){rx=min(rx,x);}
    if(a==3){ly=max(ly,y);}
    if(a==4){ry=min(ry,y);}
  }
  if(rx<=lx || ry<=ly){cout << 0 << endl;}else{cout << (rx-lx)*(ry-ly) << endl;}
}

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

int main()
{
  int a,b,c;
  int diff=0;
  
 
  cin >>a >>b>>c;
  
  diff=b-a;
  if(c-b==diff){
    cout << "YES" << endl;
  }else{
  cout << "NO"<<endl;
}
}



Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

l,r,d = na()
ans = 0

for i in range(l,r+1):
    if i%d==0:
        ans += 1

print(ans)

Measured memory_bytes: 9120
def submit():
    n, x = map(int, input().split())

    L = [0 for _ in range(n + 1)] # 総枚数
    P = [0 for _ in range(n + 1)] # パティ枚数
    L[0] = 1
    P[0] = 1

    for i in range(n):
        L[i + 1] = 3 + 2 * L[i]
        P[i + 1] = 1 + 2 * P[i]

    def search(l, r):
        if l == 0:
            return 1
        if r == 1:
            return 0

        r -= 1 # パンを食べる
        if L[l - 1] > r:
            return search(l - 1, r)
        if L[l - 1] == r:
            return P[l - 1]
        if L[l - 1] + 1 == r:
            return 1 + P[l - 1]

        r -= L[l - 1] + 1 # 下半分を食べる
        if L[l - 1] > r:
            return search(l - 1, r) + 1 + P[l - 1]
        if L[l - 1] == r or L[l - 1] + 1 == r:
            return 1 + 2 * P[l - 1]
        
    print(search(n, x))


submit()

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

int main() {
  int N, K, ans = 0;
  vector<int>h(N);
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
    if (h.at(i) >= K) {
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 16640
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int q,h,s,d,n;
    long long ans=0;
    cin>>q>>h>>s>>d>>n;
    q*=4;
	h*=2;
	s=min(s,min(q,h));
    if(s*2>d){
        ans+=static_cast<long long>(n/2)*d;
        n%=2;
    }
    ans+=static_cast<long long>(n)*s;
    cout<<ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
_n = gets.chomp.to_i
nums = gets.chomp.split(' ').map(&:to_i)
sum = nums.inject(&:+)

s1 = 0
s2 = sum
min = (s2 - s1).abs
nums.each do |num|
  s1 += num
  s2 -= num
  if (s2 - s1).abs < min
    min = (s2 - s1).abs
  elsif s2 >= s1
    next
  else
    break
  end
end

puts min


Measured memory_bytes: 1788
#14:59
#復習必要
#hashっぽい
N, K = map(int, input().split())

l = [0] * (10 ** 5 + 1)
for i in range(N):
    a, b = map(int, input().split())
    l[a] += b
cnt = 0
for i in range(1, 10 ** 5 + 1):
    cnt += l[i]
    if cnt >= K:
        print(i)
        break

Measured memory_bytes: 5736
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int a[N];
bool visit[N];

int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &a[i]);
    --a[i];
  }
  vector<int> b, r(m);
  for (int i = q - 1; i >= 0; --i) {
    if (!visit[a[i]]) {
      b.push_back(a[i]);
      visit[a[i]] = true;
    }
  }
  for (int i = 0; i < m; ++i) {
    if (visit[i]) continue;
    b.push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    r[b[i]] = i;
  }
  vector<int> freq(m + 1);
  freq[0] = n;
  for (int i = q - 1; i >= 0; --i) {
    int k = r[a[i]];
    if (freq[k]) {
      --freq[k];
      ++freq[k + 1];
    }
  }
  bool found = false;
  for (int i = 0; i < m; ++i) {
    if (freq[i]) {
      for (int j = i + 1; j < m; ++j) {
        if (b[j] < b[j - 1]) {
          found = true;
          break;
        }
      }
      break;
    }
  }
  puts(found ? "No" : "Yes");
  return 0;
}


Measured memory_bytes: 2040
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
                

                int a = int.Parse(array[0]);

                int b = int.Parse(array[1]);

            if (a <= 5)
            {
                Console.WriteLine(0);
            }else if(a <= 12)
            {
                Console.WriteLine(b / 2);
            }else
            {
                Console.WriteLine(b);
            }
            
        }
    }
}

Measured memory_bytes: 11092
N = int(input())
A = [int(input()) for _ in range(N)]

# http://tjkendev.github.io/procon-library/python/range_query/rmq_segment_tree.html
# N: 処理する区間の長さ
N0 = 2**(N-1).bit_length()
INF = 2**31-1
data = [0]*(2*N0)

# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2*k+1], data[2*k+2])

# 区間[l, r)の最小値
def query(l, r):
    L = l + N0
    R = r + N0
    s = 0
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])

        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1
        R >>= 1
    return s


for i, a in enumerate(A):
    update(i, a)

l, r = 0, 1
for _ in range(N):
    a, b = query(0, l), query(r, N)
    print(max(a, b))
    l += 1
    r += 1


Measured memory_bytes: 86360
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<map>

#define Rep(i,x,y) for (int i=x,_Lim=y;i<=_Lim;i++)
#define Dep(i,x,y) for (int i=x,_Lim=y;i>=_Lim;i--)

#define mk(a,b) make_pair(a,b)

using namespace std;

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

int Stv[1<<8];

inline int read(){
	int f=1,res=0,ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;ch=getchar();
	}
	while (ch>='0' && ch<='9') res=res*10+ch-48,ch=getchar();
	return f*res;
}
const int N=25;

inline void Getstring(int *S){
	*S=0;int ch=getchar();
	while (ch<'0' || ch>'9') ch=getchar();
	while (ch>='0' && ch<='9') S[++*S]=ch-48,ch=getchar();
}
int S[N],Ans;
int main(){
	Getstring(S);
	int Suf=0;
	Rep(i,1,*S){
		Suf+=S[i];
		if (S[i]>0){
			Ans=max(Ans,Suf-1+9*(*S-i));
//			printf("Suf=%d *S-i=%d\n",Suf,*S-i);
		}
		if (i==*S) Ans=max(Ans,Suf);
	}
	printf("%d\n",Ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                          
#define rep(i,n) for(int i=0; i<N; i++)
using namespace std;
int main()
{
  int W,H,N;
  cin >> W >> H >> N;
  vector<vector<int>> A(H,vector<int> (W));
  vector<int> x(N),y(N),a(N);
  rep(i,n){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  rep(i,n){
    if(a.at(i)==1){
      for(int j=0; j<H; j++){
        for(int k=0; k<x.at(i); k++){
          A.at(j).at(k)=1;
        }
      }
    }
    else if(a.at(i)==2){
      for(int j=0; j<H; j++){
        for(int k=x.at(i); k<W; k++){
          A.at(j).at(k)=1;
        }
      }
    }
    else if(a.at(i)==3){
      for(int j=0; j<y.at(i); j++){
        for(int k=0; k<W; k++){
          A.at(j).at(k)=1;
        }
      }
    }
    if(a.at(i)==4){
      for(int j=y.at(i); j<H; j++){
        for(int k=0; k<W; k++){
          A.at(j).at(k)=1;
        }
      }
    }
  }
  int count=0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(A.at(i).at(j)==0){
        count++;
      }
    }
  }
  cout << count << endl;
}         


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	ll X,Y,A,B,C; 
	cin >> X >> Y >> A >> B >> C; 
	
	vector<ll> p(A),q(B),r(C);
	rep(i,A) cin >> p[i];
	rep(i,B) cin >> q[i];
	rep(i,C) cin >> r[i];

	sort(p.begin(),p.end(),greater<ll>());
	sort(q.begin(),q.end(),greater<ll>());
	sort(r.begin(),r.end(),greater<ll>());

	vector<ll> yuni(X+Y+C);
	rep(i,X){
		yuni.push_back(p[i]);
	}
	rep(i,Y){
		yuni.push_back(q[i]);
	}
	rep(i,C){
		yuni.push_back(r[i]);
	}

	sort(yuni.begin(),yuni.end(),greater<ll>());
	rep(i,X+Y){
		ans += yuni[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8960
import math

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

def Knight(x,y):
    if (x+y)%3!=0:
        return 0
    depth = (x+y)//3
    if not depth<=x<=(x+y)-depth:
        return 0
    a = 1
    if 3*depth<2*y:
        return cmb(depth, 2*depth-y, mod)
    else:
        return cmb(depth, y-depth, mod)
X,Y = map(int,input().split())
print(Knight(X,Y))

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    vector<int> visited(n+1,-1);
    rep(i,0,n)cin>>a[i];

    int i=1;
    vector<int> num;
    while(visited[i]==-1){
        visited[i]=num.size();
        num.push_back(i);
        i=a[i-1];
    }

    int cnt=num.size()-visited[i]; //周期 visited[i]:最後に訪れた町i
    int l=visited[i];
    if(k<l)cout<<num[k]<<endl;
    else{
        k-=l;
        k%=cnt;
        cout<<num[l+k]<<endl;
    }
    return 0;
}



Measured memory_bytes: 6596
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
map<string,bool>D;
char c[30],s[30];
int N;
int main()
{
	scanf("%d\n",&N);
	for(;N--;)
	{
		scanf("%s%s",c,s);
		if(c[0]=='i')D[string(s)]=true;
		else puts(D[string(s)]?"yes":"no");
	}
	return 0;
}

Measured memory_bytes: 45484
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000




int main(){
    
	int A,B;
	cin>>A>>B;
	
	if(A<=9&&B<=9){
		cout<<A*B<<endl;
	}
	else{
		cout<<-1<<endl;
	}
	
    return 0;
}



Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]

ok=[0]*(N+1)

# print(ok)
for i in range(N):
    ok[A[i]]+=1
# print(ok)

ans=0
sum=0
for i in range(N+1):
    if ok[i]>=2:
        sum+=int(ok[i]*(ok[i]-1)/2)
# print("sum ",sum)
for i in range(N):
    # print(i,A[i])
    if ok[A[i]]<=1:
        ans=sum
    elif ok[A[i]]==2:
        ans=sum-1
    else:
        ans=sum-int(ok[A[i]]*(ok[A[i]]-1)/2)+int((ok[A[i]]-1)*(ok[A[i]]-2)/2)
    print(ans)


Measured memory_bytes: 26140
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
   
solve :: [Int] -> [Int] -> [Int] -> Int -> [Int]
solve xs ys zs k = 
    let
        xyList = take k $ sortBy (flip compare) [x + y| x <- xs, y <- ys]
    in
        take k $ sortBy (flip compare) [xy + z| xy <- xyList, z <- zs]

main = do
    [_,_,_,k] <- readInts
    xs <- readInts
    ys <- readInts
    zs <- readInts
    forM (take k $ solve xs ys zs k) print


Measured memory_bytes: 501116
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
ll modpow(ll base, ll exponent, ll mod)
{
	ll retval = 1;
	while (exponent > 0)
	{
		if (exponent % 2)
			retval = (retval * base) % mod;
		exponent /= 2;
		base = (base * base) % mod;
	}
	return retval;
}

class ModComb
{
public:
	ModComb(int max_n, ll mod) : m_mod(mod)  // mod and any i (1<i<=max_n) must be mutually prime. in reality mod must be a prime number and mod>max_n
	{
		m_fac.resize(max_n + 1);
		m_inv.resize(max_n + 1);
		m_fin.resize(max_n + 1);
		m_fac[0] = 1;
		m_fac[1] = 1;
		m_inv[0] = 0;  // dummy
		m_inv[1] = 1;
		m_fin[0] = 1;
		m_fin[1] = 1;
		for (int i = 2; i <= max_n; i++)
		{
			m_fac[i] = m_fac[i - 1] * i % mod;
			m_inv[i] = mod - m_inv[mod % i] * (mod / i) % mod;
			m_fin[i] = m_fin[i - 1] * m_inv[i] % mod;
		}
	}

	ll v(int n, int k)
	{
		if (n < 0 || k < 0)
			return 0;
		if (n < k)
			return 0;
		return m_fac[n] * (m_fin[k] * m_fin[n - k] % m_mod) % m_mod;
	}

private:
	ll m_mod;
	vector<ll> m_fac;  // factorial
	vector<ll> m_inv;  // inverse element
	vector<ll> m_fin;  // factorial of inverse
};

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

	ll modval = 1000000007;

	int k;
	cin >> k;
	string str;
	cin >> str;
	int s = str.length();

	ModComb nCk(s + k, modval);

	ll sum = 0;
	for (int i = 0; i <= k; i++)
	{
		ll this_cases = nCk.v(s + k - i - 1, s - 1);
		this_cases *= modpow(25, k - i, modval);
		this_cases %= modval;
		this_cases *= modpow(26, i, modval);
		this_cases %= modval;
		sum += this_cases;
		sum %= modval;
	}
	cout << sum << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 51168
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

c = Counter(s)
m = c.most_common()[0][1]
k = list(c.keys())
v = list(c.values())

l = []
for i in range(len(c)):
  if v[i] == m:
    l.append(k[i])

l.sort()
    
print(*l,sep="\n")

Measured memory_bytes: 49472
#include<bits/stdc++.h>
#define ll long long int
#define ff first
#define ss second
#define eps 1e-9

using namespace std;

int main()
{

    ll t,n,m,f,a,b,c,l,r,q,k,x,y,z,ans,mn,mx,sum=0;

    cin>>t;

   ans=0;
   x=t;
   for(int i=1;i<=3;i++)
   {
       ans+= t;
       t*=x;
   }

   cout<<ans<<endl;
}


Measured memory_bytes: 3592
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int M = nextInt();
		int D = nextInt();

		int cnt = 0;
		for(int i=1;i<=M;i++) {// i = 月
			for(int j=22;j<=D;j++) {// j = 日
				int m = j/10;
				int d = j%10;
				if(m*d==i&&j%10>1) {
					cnt++;
				}
			}
		}

		out.println(cnt);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s;
  cin>> s;
  int N=s.size();
  int a,b;
  for (int i = 0; i < N; i++) {
    if(s.at(i)=='A'){
      a=i;
      break;
    }
  }
    for (int i = N-1; i >=0; i--) {
    if(s.at(i)=='Z'){
      b=i;
      break;
    }
  }
  printf("%d",b-a+1);
}

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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   int X,Y;
   cin >> X>>Y;
   cout << X+Y/2;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String boin = scan.next();
		if(boin.equals("a") || boin.equals("i") || boin.equals("u") || boin.equals("e") || boin.equals("o")){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}

	}

}

Measured memory_bytes: 21844
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int sum = 0;
			for(int i = 0; i < 5; i++) {
				int tmp = sc.nextInt();
				sum += tmp<40?40:tmp;
			}
			System.out.println(sum/5);
		}
	}
}


Measured memory_bytes: 26412
from collections import deque,Counter
n,m=map(int,input().split())
a=[deque(list(map(int,input().split()))) for _ in range(n)]
ans=n
no=set(())
while len(no)<m:
  for i in range(n):
    while a[i][0] in no:
      a[i].popleft()
  top=[a[i][0] for i in range(n)]
  ctop=Counter(top)
  mm=max(ctop.values())
  ans=min(ans,mm)
  for c in ctop:
    if ctop[c]==mm:
      no.add(c)
print(ans)


Measured memory_bytes: 77276
n = int(input())

counter_outer = 0

for i in range(1, n+1, 2):
 counter_inner = 0
 for j in range(1, int(i**0.5) + 1):
     if i%j == 0:
       counter_inner += 1
 if(counter_inner == 4):
   counter_outer += 1

print(counter_outer)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
int main(){
    int n;
    int a[110];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    int ans = 10000000;
    int total = 0;
    for(int i = -100; i < 101; i++){
        for(int j = 0; j < n; j++)  total += (i - a[j])*(i - a[j]);
        if(total < ans) ans = total;
        total = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
while True:
	n = int(input())
	if n == 0: break
	s, vmin, vmax = 0, 1001, -1
	for i in range(n):
		a = int(input())
		vmin = min(vmin, a)
		vmax = max(vmax, a)
		s += a
	print((s-vmin-vmax)//(n-2))



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

int main() {
    int N, Y;
    cin >> N >> Y;
    int ansx = -1;
    int ansy = -1;
    int ansz = -1;


    for(int i = 0; i <= 2000; i++){
        for(int j = 0; j <= 2000 - i; j++){
            if(i*10000+j*5000+1000*(N-i-j) == Y && N-i-j >=0){
                ansx = i;
                ansy = j;
                ansz = N - i - j;
            }
        }
    }
    cout << ansx <<" "<< ansy <<" "<< ansz << endl;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun h w ->
    let s = Array.init h (fun _ -> Scanf.scanf " %s" (fun s -> s)) in
    let mat = Array.make_matrix h w 100000 in
    mat.(0).(0) <- if s.(0).[0] = '#' then 1 else 0;
    for y = 0 to h - 1 do
        for x = 0 to w - 1 do
            if x < w - 1 then (
                let q = if s.(y).[x] = '.' && s.(y).[x + 1] = '#' then 1 else 0 in
                mat.(y).(x + 1) <- min mat.(y).(x + 1) (mat.(y).(x) + q)
            );
            if y < h - 1 then (
                let q = if s.(y).[x] = '.' && s.(y + 1).[x] = '#' then 1 else 0 in
                mat.(y + 1).(x) <- min mat.(y + 1).(x) (mat.(y).(x) + q)
            );
         done
    done;
    Printf.printf "%d\n" mat.(h - 1).(w - 1)
)

Measured memory_bytes: 3860
n = int(input())
cards = {} #空の辞書
for i in range(n):
    card = input()
    cards[card] = 1
    
#print(cards)

for c in ['S', 'H', 'C', 'D']:
    for n in range(1,14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)


Measured memory_bytes: 5600
#include <stdio.h>
#include <stdlib.h>
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) > (b) ? (b) : (a))

int asc(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int
main(int argc, char *argv[])
{
  int n; int d[100000];
  scanf("%d", &n);
  for(int i= 0; i < n; i++) scanf("%d", &d[i]);

  qsort(d, n, sizeof(int), asc);

  printf("%d\n", d[n/2] - d[n/2 - 1]);
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<(ll)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll dp[200200]={};
int main(){
    fast_io
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(), a.end());
    int sum=0;
    int ans=1;
    rep(i,n-1){
        if(a[i]==a[i+1]){
            sum++;
        }
        else ans++;
    }
    if(ans%2==0) ans--;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    }
  int k=1;
  for(int i=0;i<n*100;i++){
    k=vec.at(k-1);
    if(k==2){
      cout<<i+1<<endl;
      return 0;
      }
    }
  cout<<"-1"<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	
	int r, g,ans;
	cin >> r >> g;
	ans = g * 2 - r;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x,y;
    int flag=0;
    int e1max=-1002,e2min=9999,num;
    cin>>n>>m>>x>>y;
    for(int i=0;i<n;i++)
    {
        cin>>num;
        if(num>e1max)
            e1max=num;
    }
    for(int i=0;i<m;i++)
    {
        cin>>num;
        if(num<e2min)
            e2min=num;
    }

    if(e2min>e1max)
    {
        for(int i=e2min;i>=-100;i--)
        {
            if(i>e1max)
            {
                if(i<=y&&i>x)
                {
                    flag=1;
                    break;
                }
            }
            else
                break;
        }
        if(flag)
            printf("No War\n");
        else
            printf("War\n");
    }
    else
        printf("War\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
int main()
{
        long long n,i,fac;
        scanf("%lld",&i);
        fac=1;
        for(;i>1;i--)
                {
                        fac=fac*i;
                }

        printf("%lld\n",fac);

        return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0

int s,ans,cnt;
int a[15];

signed main() {
	cin >> s;
	for (int i = 0; i < 11; i++) {
		if (s == 0) {
			cnt = i - 1;
			break;
		}
		a[i] = s % 10;
		s /= 10;
	}
	reverse(a, a + cnt + 1);
	for (int i = 0; i < (1 << cnt); i++) {
		int bit[15];
		for (int j = 0; j < cnt; j++) {
			bit[j] = (i / (1 << j)) % 2;
		}
		int num = a[0];
		for (int j = 0; j < cnt; j++) {
			if (bit[j] == 0) {
				num = num * 10 + a[j + 1];
			}
			else {
				ans += num;
				num = a[j + 1];
			}
		}
		ans += num;
	}
	cout << ans << endl;
	END;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

ll MOD = 1e9 + 7;
ll FAC_MAX = 2000;

ll mpow(ll a, ll n) {  // a^n (mod MOD)
    // 二分累乗法 O(log n)
    ll ans = 1;
    while (n != 0) {
        if (n & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ans;
}

vi fac_vec;
ll fac(ll n) {  // n! (mod MOD)
    if (fac_vec.empty()) {
        fac_vec = vi(FAC_MAX + 10);  // (FAC_MAX+10)! まで対応
        fac_vec[0] = 1;
        for (ll i = 1; i < fac_vec.size(); i++) {
            fac_vec[i] = fac_vec[i - 1] * i % MOD;
        }
    }
    return fac_vec[n];
}

vi ifac_vec;
ll ifac(ll n) {  // (n!)^(-1) (mod MOD)
    // フェルマーの小定理より、k^(-1)≡k^(MOD-2) なので、
    // (n!)^(-1)≡(n!)^(MOD-2)
    if (ifac_vec.empty()) {
        ifac_vec = vi(FAC_MAX + 10);  // {(FAC_MAX+10)!}^(-1) まで対応
        ifac_vec[0] = 1;
        for (ll i = 1; i < ifac_vec.size(); i++) {
            ifac_vec[i] = ifac_vec[i - 1] * mpow(i, MOD - 2) % MOD;
        }
    }
    return ifac_vec[n];
}

ll comb(ll a, ll b) {  // aCb (mod MOD)
    // aCb = a! * (b!)^(-1) * {(a-b)!}^(-1)
    if (a < b || a < 0 || b < 0) return 0;
    return (ifac(b) * ifac(a - b) % MOD) * fac(a) % MOD;
}

int main() {
    ll N, K;
    cin >> N >> K;

    for (ll i = 1; i <= K; i++) {
        // 青を入れる場所 comb(N - K + 1, i)
        // 青の分け方 comb(K - 1, i-1)
        ll ans = comb(N - K + 1, i) * comb(K - 1, i - 1) % MOD;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 75, K = 75;
const long long mod = 1000000007ll;

int n, m, stk[N], pos[N], suf[K], tmp[N], top = 0;
char str[K];
bool vis[K];
long long c[N * 5][N * 5], ans = 0ll;

bool check () {
	vector<int> vec1, vec2, vec3;
	for (int i = 0; i < top; i++) vec1.push_back(stk[i]);
	for (int i = 0; i < m; i++) {
		if (str[i] == 'r') {
			if (!vec1.empty()) {
				if (vec1.back()) vec2.insert(vec2.begin(), vec1.back());
				vec1.pop_back();
			}
			else if (!vec3.empty()) {
				(*vec3.rbegin())--;
				if (!vec3.back()) vec3.pop_back();
			}
		}
		else {
			if (!vec2.empty()) {
				if (vec2.back() > 1) vec3.push_back(vec2.back() - 1);
				vec2.pop_back();
			}
			else if (!vec3.empty()) {
				(*vec3.rbegin())--;
				if (!vec3.back()) vec3.pop_back();
			}
		}
	}
	return vec1.empty() && vec2.empty() && vec3.empty();
}
long long solve () {
	if (!check()) return 0ll;
	long long res = 1ll;
	for (int i = 0; i <= n; i++) tmp[i] = 0;
	for (int i = 0; i < top; i++) tmp[stk[i]]++;
	for (int i = 0, j = 0; i <= n; i++) {
		j += tmp[i];
		assert(j <= n * 3 && tmp[i] <= n * 3);
		res = res * c[j][tmp[i]] % mod;
	}

	int num1 = 0, num2 = 0;
	for (int i = 0; i < top; i++) {
		if (stk[i]) num1 += 2 * stk[i] - 1, num2 += 2;
		else num1++;
	}
	if (top) num1 += top - 1, num2 += 2;
	else num1++;
	if (n + num2 - 1 < 0 || num1 + num2 - 1 < 0) return 0ll;
	if (n + num2 - 1 > n * 5 || num1 + num2 - 1 > n * 5) return 0ll;
	res = res * c[n + num2 - 1][num1 + num2 - 1] % mod;
	return res;
}

void dfs (int mn, int total) {
	if (mn == n + 1) ans = (ans + solve()) % mod;
	if (mn <= n) dfs(mn + 1, total);
	int t = mn ? mn << 1 : 2;
	if (total + t <= n + 1) {
		stk[top++] = mn;
		dfs(mn, total + t);
		top--;
	}
}

int main () {
	scanf("%d%d%s", &n, &m, str);
	for (int i = 0; i <= n * 5; i++) {
		for (int j = 0; j <= n * 5; j++) c[i][j] = 0ll;
	}
	for (int i = 0; i <= n * 5; i++) c[i][0] = c[i][i] = 1ll;
	for (int i = 1; i <= n * 5; i++) {
		for (int j = 1; j < i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
	}
	dfs(0, 0);
	printf("%lld\n", ans);
	return 0;
}

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


int main() {
  // ここにプログラムを追記
  string n;
  cin >> n ;

  if(n.at(0)=='7'){
    cout << "Yes" << endl;
  }else if(n.at(1)=='7'){
    cout << "Yes" << endl;
  }else if(n.at(2)=='7'){
    cout << "Yes" << endl;
  }else

  

  
  cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

inline void solve() {
    string s;
    cin >> s;

    if (s == "RRR") {cout << 3 << endl;}
    else if (s == "RRS" || s == "SRR") {cout << 2 << endl;}
    else if (s == "SSS") {cout << 0 << endl;}
    else {cout << 1 << endl;}
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3608
def internal(a)
    a.each_with_index.inject(0) do |sum, (ai, i)|
        sum += a[i+1..-1].count{|aj| ai > aj}
    end
end

def external(a)
    a.inject(0) do |sum, ai|
        sum += a.count{|aj| ai > aj}
    end
end

N, K = gets.split.map &:to_i
A = gets.split.map &:to_i
p (K * internal(A) + (K * (K - 1) / 2) * external(A)) % (10**9 + 7)

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	/*
	 * 問題文 日本の誇る美しいリズムとして、五七五というものがあります。
	 * いろはちゃんは五七五が大好きです。
	 *
	 * 3 つの文節の並びの長さがそれぞれ 5,7,5 となるようにこの順番で並んでいるとき、
	 * その 3 つの文節の並びは五七五であると言います。
	 *
	 * 並び替えたい 3 つの文節の長さを表す整数 A,B,C が与えられるので、
	 * それらの文節を並び替えて五七五にできるか判定してください。
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int f=0;
		int s=0;
		for (int i = 0; i < 3; i++) {
			int str= sc.nextInt();
			if (str == 5) {
				f++;
			} else if(str==7){
				s++;
			}


		}
		if (s==1&&f==2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}


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

#ifdef __WIN32
#define LLFORMAT "I64"
#else
#define LLFORMAT "ll"
#endif

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), b(n), c;
	vector<long long> s(n * 2 + 1, 0);
	long long x = 0, y = 0;
	for (int i = 0; i < n; ++i) cin >> a[i] >> b[i], c.push_back(a[i]), c.push_back(b[i]), x += a[i], y += b[i];
	long long ans = min(x, y);
	sort(c.begin(), c.end());
	for (int i = 0; i < n * 2; ++i) s[i + 1] = s[i] + c[i];
	for (int i = 0; i < n; ++i) {
		int x = lower_bound(c.begin(), c.end(), a[i]) - c.begin();
		int y = lower_bound(c.begin(), c.end(), b[i]) - c.begin();
		if(x == y) ++y;
		if(x > y) swap(x, y);
		int t = n - 2;
		long long sum = a[i] + b[i];
		if(x < t) sum -= c[x], ++t;
		if(y < t) sum -= c[y], ++t;
		sum += s[t];
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


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

class Dice {
public:
    int d[6];
    void roll(int i, int j, int k, int l) {
        int t = d[i];
        d[i] = d[j];
        d[j] = d[k];
        d[k] = d[l];
        d[l] = t;
    }

    void roll_x() {
        roll(0, 1, 5, 4);
    }
    
    void roll_y() {
        roll(0, 2, 5, 3);
    }

    void move(char ch) {
        if (ch == 'N') roll_x();
        if (ch == 'W') roll_y();
        if (ch == 'E') for(int i=0; i<3; ++i) roll_y();
        if (ch == 'S') for(int i=0; i<3; ++i) roll_x();
    }
};


        
int main() {
    Dice dice;
    for(int i=0; i<6; ++i) cin >> dice.d[i];
    string s;
    cin >> s;

    for(int i=0; i<s.size(); ++i) {
        dice.move(s[i]);
    }

    cout << dice.d[0] << endl;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005
#define PI 3.141592653589793
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int, int>;

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

int main()
{
    int H, W; cin >> H >> W;
    int CH, CW; cin >> CH >> CW; --CH; --CW;
    int DH, DW; cin >> DH >> DW; --DH; --DW;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    deque<P> que;
    que.emplace_back(make_pair(CH, CW));//スタート
    vector<vector<int>> cost(H, vector<int>(W, INF));
    cost[CH][CW] = 0;

    while(!que.empty()){
        P target = que.front(); que.pop_front();
        int targetCost = cost[target.first][target.second];
        
        //徒歩
        rep(i, 4){
            int nextY = target.first + dy[i];
            int nextX = target.second + dx[i];
            if(nextY < 0 || H <= nextY || nextX < 0 || W <= nextX) continue; //表示内か
            if(S[nextY][nextX] == '#') continue; //道か
            if(cost[nextY][nextX] <= targetCost) continue; //他のルートの方が少ないコストか
            cost[nextY][nextX] = targetCost;
            que.emplace_front(make_pair(nextY, nextX));
        }

        //魔法
        for(int i = -2; i <= 2; ++i){
            for(int j = -2; j <= 2; ++j){
                int nextY = target.first + i;
                int nextX = target.second + j;
                if(nextY < 0 || H <= nextY || nextX < 0 || W <= nextX) continue; //表示内か
                if(S[nextY][nextX] == '#') continue; //道か
                if(cost[nextY][nextX] <= targetCost + 1) continue; //他のルートの方が少ないコストか
                cost[nextY][nextX] = targetCost + 1;
                que.emplace_back(make_pair(nextY, nextX));
            }
        }
    }

    int ans = cost[DH][DW] == INF ? -1 : cost[DH][DW];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9444
#include<stdio.h>
int main(void){
    int N, X, T, ans;
    scanf("%d%d%d", &N, &X, &T);
    if(N % X == 0) ans = N / X * T;
    else ans = (N / X + 1) * T;
    printf("%d", ans);
    return 0;

}

Measured memory_bytes: 1692
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define FF first
#define SS second
#define pii pair<int,int>
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
#define mp make_pair
#define Mod 1000000007
typedef long long int ll;
// g++ -DLOCAL -std=c++17 -Wshadow -Wall  "codeforces.c++" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g

// dp[i] -> store result whether present player playing the tuen is able to win or not if i stones left

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// #endif

	int n, l, r;

	cin >> n;
	vector<int> seq(n);

	for(int &x : seq)
		cin >> x;
	// cout<<seq.size()<<"\n";
	// for(int x : seq)
	// 	cout<<x<<" ";

	vector<vector<ll>> dp(n, vector<ll>(n));

	for(l = n-1; l >= 0; l--)
		for(r = l; r < n; r++){
			// cout<<l<<" "<<r<<"\n";
			if(l == r)
				dp[l][r] = seq[l];
			else
				dp[l][r] = max(seq[l] - dp[l+1][r], seq[r] - dp[l][r-1]);
		}

	cout<<dp[0][n-1]<<"\n";


}	


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
int main(){
  char N;
  cin >> N;
  string A= "abcdefghijklmnopqrstuvwxyz";
  
  for (int i=0;i<100; i++) {
    if(N==A[i]) {
      cout << A[i+1] << endl;
      return 0;
    }
  }

  return 0;
  
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int res = (1 << 29);
    for (int i = -100; i <= 100; i++) {
        int total_cost = 0;
        for (int j = 0; j < N; j++) {
            total_cost += (i - a[j]) * (i - a[j]);
        }
        res = min(res, total_cost);
    }
    cout << res << endl;
    return 0;
}


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

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

  auto get_same_num = [&](int pos) {
    string f = s.substr(0, pos);
    string l = s.substr(pos);

    int count = 0;
    char c = 'a';
    while (c <= 'z') {
      if (f.find(c) != string::npos && l.find(c) != string::npos) count++;
      c++;
    }
    return count;
  };

  int ans(0);
  for (int i = 1; i < n - 1; i++) {
    ans = max(get_same_num(i), ans);
  }

  cout << ans << endl;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  i64 A, B;
  cin >> A >> B;
  i64 maxv = -100000000;
  chmax(maxv, A + B);
  chmax(maxv, A - B);
  chmax(maxv, A * B);
  cout << maxv << endl;

  return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;


vll sieve(ll n) {
    vll res(n + 1);
    iota(all(res), 1); // res[6] = 7は　約分する前にx/6の形の分数が7個あることを意味する
    for (ll i = 1; i <= n; i++) {
        for (ll j = 2 * i ; j <= n ; j += i) {
            res[j] -= res[i];
        }
    }
    return res;
}

int main() {
    vll res = sieve(1000010);
    vll Sum(1000010);
    Sum[1] = res[1];
    for (int i = 2; i < 1000010; i++) Sum[i] = Sum[i - 1] + res[i];

    int t, n; cin >> t;
    rep(i, t) {
        cin >> n;
        cout << Sum[n] << endl;
    }

}


Measured memory_bytes: 18220