akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int N, K;
    int l[110];
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> l[i];
    }
    sort(l, l+N, greater<int>());
    int sum = 0;
    
    for(int i=0; i<K; i++){
        sum += l[i];
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int w= sc.nextInt();
		int n= sc.nextInt();
		int[] values=new int[w];
		for(int i=0;i<values.length;i++){
			values[i]=i+1;
		}
		for(int i=0;i<n;i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int c;
			c=values[a];
			values[a]=values[b];
			values[b] =c;
		}
		for(int i=0;i<values.length;i++){
			System.out.printf("%d\n",values[i]);
		}
	}
}

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

int main(){
    int n,i;
    cin>>n;
    int arr[2][n];
    for(i=0;i<n;i++){
        cin>>arr[0][i]>>arr[1][i];
    }
    bool ok=0;
    for(i=2;i<n;i++){
        if(arr[0][i-2] == arr[1][i-2] && arr[0][i-1] == arr[1][i-1] && arr[0][i] == arr[1][i]){
            ok=1;
        }
    }
    if(ok)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){
	
	string s;
	int n, w=0, e=0;
	cin >> n;
	cin >> s;

	for(int i=0; i<n; i++){
		if(s[i]=='E'){
			e++;
		}
	}
	int ans=e, tmp=e;
	for(int i=0; i<n; i++){
		if(s[i]=='W'){
			w++;
		} else {
			e--;
		}
		tmp=min(tmp, e+w);
	}
	cout << tmp << endl;
	
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
 
int N,K,a[100010],cnt[40];
int dp[40][2];


signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>K;
    rep(i,0,N){
        cin>>a[i];
        int A=a[i];
        int tmp=0;
        while(A){
            if(A&1)cnt[tmp]++;
            A/=2;
            tmp++;
        }
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    rep(i,0,40)rep(j,0,2){
        if(dp[i][j]<0)continue;
        int t=40-1-i;
        int lim=j?1:((K&(1ll<<t))>0);
        rep(d,0,lim+1){
            int sum=0;
            rep(l,0,N)sum+=(d<<t)^(a[l]&1ll<<t);
            chmax(dp[i+1][j||d<lim],dp[i][j]+sum);
        }
    }
    cout<<max(dp[40][0],dp[40][1])<<endl;
    
    
    
    return 0;
}

Measured memory_bytes: 1024
from itertools import combinations

n,x,y = map(int,input().split())

num = []
for i in range(1,n+1):
    num.append(i)

ans = [0] * (n+1)

for i,j in combinations(num,2):
    ans[min(abs(j-i),abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x))] += 1

for i in range(n-1):
    print(ans[i+1])

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

int main(){
    int64_t A,B,K;
    cin >> A >> B >> K;
    
    if ( K >= A ){
        B = B - ( K - A );
        A = 0;
    } else {
        A = A - K;
    }
    if ( A < 0 ) A = 0;
    if ( B < 0 ) B = 0;
    
    cout << setprecision(15) << A << " " << setprecision(15) << B << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 5e6+100;
const int mod = 1e9+7;
char arr[upperlimit];
int main() {
	int n,m,k;
	sd(n);
	sd(m);
	sd(k);
	double ans;
	if(k==0){
		ans=m-1;
		ans/=n;
	}
	else{
		ans=n-k;
		ans*=2;
		ans*=m-1;
		ans/=n;
		ans/=n;
	}
	printf("%0.9f\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N < 105){
        	System.out.println(0);
        	return;
        }
      	int Ncnt = 0;
      	for(int i = 1; i < N+1; i+=2){
          	Integer hN = (int) Math.floor(N/2);
          	int cnt = 2;
        	for(int j = 2; j < hN; j++){
              	if(i%j==0){
                	cnt++;
                }
            }
          	if(cnt==8){
              Ncnt++;
            }
        }
		System.out.println(Ncnt);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}




int main() {
	ll N, M;
	cin >> N >> M;
	string an = "";
	rep(i, N) {
		an += '?';
	}
	rep(i, M) {
		ll s;
		char c;
		cin >> s >> c;
		if (an.at(s - 1) == '?')an.at(s - 1) = c;
		else if (an.at(s - 1) == c)continue;
		else {
			cout << -1 << endl; return 0;
		}
	}
	if (an.at(0) == '?'&&N==1) {
		an.at(0) = '0'; 
	
	}
	else if (an.at(0) == '?' && N != 1)an.at(0) = '1';
	else if (an.at(0) == '0'&&N!=1) {
		cout << -1 << endl; return 0;
	}
	rep(i, N - 1) {
		if (an.at(i + 1) == '?')an.at(i + 1) = '0';
	}
	rep(i, N)cout << an.at(i);
	cout << endl;
}



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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    string s;
    cin>>s;
    int q;
    cin>>q;
    int cur=0;
    while(q--) {
        int op;
        cin>>op;
        if(op==1)cur++;
        else {
            int f;
            char c;
            cin>>f>>c;
            if(f==1) {
                if(cur%2==0) {
                    s=c+s;
                } else {
                    s+=c;
                }
            } else {
                if(cur%2==0) {
                    s+=c;
                } else {
                    s=c+s;
                }
            }
        }
    }
    if(cur&1) {
        reverse(all(s));
        cout<<s<<endl;
    }else cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 4680
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define ll long long
#define MAX 100100
inline ll read()
{
	ll x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
map<ll,int> M,vis;
int n,tot,ans;
ll a[MAX],b[MAX],p[MAX],pri[MAX];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=2;i<=2500;++i)
	{
		bool fl=true;
		for(int j=2;j<i;++j)if(i%j==0){fl=false;break;}
		if(fl)pri[++tot]=i;
	}
	for(int i=1;i<=n;++i)
	{
		p[i]=b[i]=1;
		for(int j=1;j<=tot&&a[i]>1;++j)
			if(a[i]%pri[j]==0)
			{
				int cnt=0;
				while(a[i]%pri[j]==0)a[i]/=pri[j],++cnt;
				cnt%=3;if(!cnt)continue;
				if(cnt==1)p[i]*=1ll*pri[j]*pri[j],b[i]*=pri[j];
				else p[i]*=pri[j],b[i]*=1ll*pri[j]*pri[j];
			}
		if(a[i]==1)continue;
		ll s=sqrt(a[i]);b[i]*=a[i];
		if(s*s==a[i])p[i]*=s;
		else p[i]*=a[i]*a[i];
	}
	for(int i=1;i<=n;++i)++M[b[i]];
	for(int i=1;i<=n;++i)
	{
		if(vis[b[i]])continue;
		if(b[i]!=p[i])ans+=max(M[b[i]],M[p[i]]);
		else ans+=1;
		vis[b[i]]=vis[p[i]]=1;
	}
	printf("%d\n",ans);
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, q, h, s, d;

int main() {
	cin >> q >> h >> s >> d >> n;
	
	LL one = min(min(q * 4, h * 2), s);
	LL two = min(one * 2, d);
	
	cout << ((n / 2) * two + (n % 2) * one) << endl;
	
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
	int N;
	cin >> N;
	vector<int> vec(N);
	int a;
	rep(i, N - 1) {
		cin >> a;
		vec.at(a - 1)++;
	}
	rep(i, N) cout << vec.at(i) << endl;
}

Measured memory_bytes: 4052
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, h, a, b = 1; cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> h;
		if (i == 1) {
			a = h;
		}
		else {
			if (a <= h) {
				b++;
				a = h;
			}
		}
	}
	cout << b << endl;
	cin >> n;
}

Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline

    a, b, c, d = [int(x) for x in input().rstrip().split(" ")]

    ans = -float("inf")
    for x in [a, b]:
        for y in [c, d]:
            tmp = x * y
            if ans < tmp:
                ans = tmp

    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 61760
#include<stdio.h>
int main(void){
  int k,rank1,rank2;
  int height[11];
  int first=0,second=0,third=0;
  for(k=1;k<=10;k++){
    scanf("%d",&height[k]);
  }
  for(k=1;k<=10;k++){
    if(first<height[k]){
      first=height[k];
      rank1=k;
    }
  }
  for(k=1;k<=10;k++){
    if(second<height[k]&&k!=rank1){
      second=height[k];
      rank2=k;
    }
  }
  for(k=1;k<=10;k++){
    if(third<height[k]&&k!=rank1&&k!=rank2){
      third=height[k];
    }
  }
  printf("%d\n%d\n%d\n",first,second,third);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  bool flag = true;
  if (n % 2 == 0) {
    for (int i = 0; i < n; i += 2) {
      if (a.at(i) == a.at(i + 1) && a.at(i) == i + 1) continue;
      else flag = false;
    }
  } else {
    if (a.at(0) != 0) flag = false;
    for (int i = 1; i < n; i += 2) {
      if (a.at(i) == a.at(i + 1) && a.at(i) == i + 1) continue;
      else flag = false;
    }
  }
  ll ans = 1;
  if (flag) {
    for (int i = 0; i < n / 2; i++) {
      ans = ans * 2 % 1000000007;
    }
  } else {
    ans = 0;
  }
  cout << ans << endl;
}


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

int main(){
  long long n,d,ans=0;
  cin >> n >> d;
  for(int i = 0; i < n; i++){
    long long a,b;
  	cin >> a >> b;
    if(a*a + b*b <= d*d){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	string S;
	cin >> S;
	size_t s = S.size();
	bool f1 = false, f2 = false, f3 = false;
	if (S[0] == 'A') { f1 = true; }
	
	int C = 0;
	for (int i = 2; i < s - 1; i++) {
		if (S[i] == 'C') { C++; }
	}
	if (C == 1) { f2 = true; }

	int L = 0;
	for (int i = 0; i < s; i++) {
		if (S[i] >= 'A' && S[i] <= 'Z') { L++; }
	}
	if (L == 2) { f3 = true; }

	if (f1 && f2 && f3){
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> D(N);
    for (int i = 0; i < N; i++) cin >> D[i];
    vector<vector<pair<int, int>>> edge(N+1);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        edge[u].push_back({v, i+1});
        edge[v].push_back({u, i+1});
    }
    vector<int> anse(M+1, 1000000000), ansv(N+1, 0);
    vector<pair<int, int>> p(N);
    for (int i = 0; i < N; i++) p[i] = {D[i], i+1};
    sort(p.begin(), p.end());
    if (p[0].first != p[1].first) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < N; i++) {
        int now = p[i].second;
        if (ansv[now] > 0) continue;
        for (auto pair : edge[now]) {
            int nxt = pair.first;
            if (ansv[nxt] > 0) {
                anse[pair.second] = p[i].first;
                ansv[now] = 3-ansv[nxt];
                break;
            }
        }
        if (ansv[now] == 0) {
            int me = edge[now][0].second, mv = edge[now][0].first;
            for (auto pair : edge[now]) {
                if (D[mv-1] > D[pair.first-1]) {
                    mv = pair.first;
                    me = pair.second;
                }
            }
            if (D[mv-1] > D[now-1]) {
                cout << -1 << endl;
                return 0;
            }
            anse[me] = D[now-1];
            ansv[now] = 1;
            ansv[mv] = 2;
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << ((ansv[i] == 1) ?  'B' : 'W');
    }
    cout << endl;
    for (int i = 1; i <= M; i++) {
        cout << anse[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n;
  cin >> n;
  vector<int> v=input(n);
  vector<int> c=input(n);
  
  vector<int> vc(20);
  rep(i,n){
    vc[i]=(v[i]-c[i]);
  }
  
  sort(vc.begin(),vc.end());
  reverse(vc.begin(),vc.end());
  
  int ans=0;
  rep(i,n){
    if(vc[i]>0){
      ans += vc[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var line string
	fmt.Scan(&n, &line)
	black, white := 0, 0
	blacks, whites := make([]int, n + 2), make([]int, n + 2)
	for i, l := range line {
		s := string(l)
		if s == "#" {
			black++
		}
		if s == "." {
			white++
		}
		blacks[i + 1] = black
		whites[i + 1] = white
	}
	blacks[n + 1] = blacks[n]
	whites[n + 1] = whites[n]
	min := math.MaxInt32
	for i := 0; i < n + 1; i++ {
		w, b := whites[n + 1] - whites[i + 1], blacks[i]
		if w + b < min {
			min = w + b
		}
	}
	fmt.Println(min)
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define vi vector<int>

using namespace std;

ll n, m, temp, ans, temp_div;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    m = n - 1;

    ans = 0;
    for(ll i=1; i * i <= m; ++i) {
        if(m % i == 0) {
            ans++;
            if(i*i != m) {
                ans++;
            }
        }
    }

    for(ll i=2; i * i <= n; ++i) {
        if(n % i == 0) {

            temp = n;
            while(temp % i == 0) {
                temp /= i;
            }

            //cout << temp << ' ' << i << endl;
            
            if(temp % i == 1) {
                ans++;
            }

            if(i * i != n) {
                temp_div = n / i;
                temp = n;

                while(temp % temp_div == 0) {
                    temp /= temp_div;
                }

                if(temp % temp_div == 1) {
                    ans++;
                }

            }
        }
    }

    cout << ans << endl;


    return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const int MAX   = 10000;
const int INF   = (1 << 20);
const int white = 0;
const int gray  = 1;
const int black = 2;

int                    n;
vector<pair<int, int>> adj[MAX];  // 重み付き有向グラフの隣接リスト表現

int dijkstra() {
    priority_queue<pair<int, int>> pq;
    int                            d[MAX], color[MAX];
    rep(i, n) {
        d[i]     = INF;
        color[i] = white;
    }

    d[0] = 0;
    pq.push(make_pair(0, 0));
    color[0] = gray;

    while (!pq.empty()) {
        pair<int, int> f = pq.top();
        pq.pop();
        int u    = f.second;
        color[u] = black;

        // 最小値を取り出し、それが最短でなければ無視
        if (d[u] < f.first * (-1)) continue;

        rep(j, adj[u].size()) {
            int v = adj[u][j].first;
            if (color[v] == black) continue;
            if (d[v] > d[u] + adj[u][j].second) {
                d[v] = d[u] + adj[u][j].second;
                // priority_queueはデフォルトで大きい値を優先するため-1を掛ける。
                pq.push(make_pair(d[v] * (-1), v));
                color[v] = gray;
            }
        }
    }
    rep(i, n) { cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl; }
}

// 単一始点最短経路 part2
// 二分ヒープ(優先度付きキュー）
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int k, c, u, v;
    cin >> n;
    rep(i, n) {
        cin >> u >> k;
        rep(j, k) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}



Measured memory_bytes: 8084
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,i;
int main(){
	cin>>n;
	for(i=0;i<n;i++){
	  cin>>a>>b>>c;
	  if(a>b){
		swap(a,b);
	  }
	  if(a>c){
	    swap(a,c);
	  }
	  if(b>c){
	    swap(b,c);
	  }
	  if(c*c==a*a+b*b){
		   cout<<"YES"<<endl;
	  }
	  else{
		  cout<<"NO"<<endl;
	  }
    }
}		  



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

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

n_r, n_g, n_b = 0, 0, 0
for i in range(N):
    if S[i] == 'R':
        n_r += 1
    elif S[i] == 'G':
        n_g += 1
    else:
        n_b += 1
# print(n_r, n_g, n_b)

n_ignore = 0
for i in range(N):
    for j in range(N):
        k = 2 * j - i
        if k >= N:
            continue
        cond_first = i < j < k
        cond_second = S[i] != S[j] and S[i] != S[k] and S[j] != S[k]
        if cond_first and cond_second:
            n_ignore += 1

res = n_r * n_g * n_b - n_ignore
print(res)


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


int solve (int n,int k,int g[],int h[])
{
    if(n==1){
        
        h[0]=0;
    
        return  h[n-1];
    }
    
    if(h[n-1] ==INT_MAX)
    solve(n-1,k, g,h);
    
    for(int i =1; i<=min(k,n-1); i++){
        
        h [n-1] = min(h[n-1-i]+abs(g[n-1]-g[n-1-i]), h[n-1]);
        }
    return h[n-1];
}


int main() {

    int n,k; cin>>n>>k;
    int g[n],h[n];
    for(int i=0; i<n; i++)
    {
        cin>>g[i];
        h[i]=INT_MAX;
    }
    cout<<solve(n,k,g,h);
    

	return 0;
}


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

int main() {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int N;
  cin >> N;
  


    cout << a[N-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,M;
  while(cin >> N >> M){
    int ans = (1<<30) - 1;
    REP(i,N){
      int t = 0;
      int K; cin >> K;
      REP(j,K){
        int A; cin >> A; --A;
        t |= (1<<A);
      }
      ans &= t;
    }
    cout << __builtin_popcount(ans) << 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);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(N*A<B){
          System.out.println(N*A);
        }else{
          System.out.println(B);
        }
      }
    }
          

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

int gcd(int a, int b)
{
    if (a < b)
    {
        int t = a;
        a = b;
        b = t;
    }
    int c = a % b;
    if (c)
        return gcd(b, c);
    else
        return b;
}
int main()
{
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            for (int k = 1; k <= n; ++k)
                sum += gcd(i, gcd(j, k));
    cout << sum;
    return 0;
}

Measured memory_bytes: 3624
n, limit = gets.split.map(&:to_i)
ct = Array.new(n, Array.new(2))
n.times{|i| ct[i] = gets.split.map(&:to_i)}
r = []
ct.each{|e| r << e[0] if e[1] <= limit }
puts r.size.zero? ? 'TLE' : r.min


Measured memory_bytes: 1788
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
using namespace std;
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fil(a,b) memset((a),(b),sizeof(a))
#define cl(a) fil(a,0)
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define forg(i,gu) for (int i=gu;~i;i=e[i].next)
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
void getre(){int x=0;printf("%d\n",1/x);}
void gettle(){int res=1;while(1)res<<=1;printf("%d\n",res);}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}
template<typename N,typename PN>inline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}
template<typename N,typename PN>inline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
template<typename N>inline int sgn(N a){return a>0?1:(a<0?-1:0);}
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld "%I64d"
#else
#define lld "%lld"
#endif
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#ifdef JCVB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
typedef long long ll;
typedef double db;
inline ll sqr(ll a){return a*a;}
inline db sqrf(db a){return a*a;}
const int inf=0x3f3f3f3f;
const db pi=3.14159265358979323846264338327950288L;
const db eps=1e-6;
//const int mo=0;
//int qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}
 
int main()
{
#ifdef JCVB
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	int _time_jc=clock();
#endif
	char s[20];
	scanf("%s",s);
	rep(i,0,4)putchar(s[i]);
	putchar(' ');
	rep(i,4,12)putchar(s[i]);
	putchar('\n');
 
 
#ifdef JCVB
	debug("time: %d\n",int(clock()-_time_jc));
#endif
	return 0;
}
 


Measured memory_bytes: 256
from math import cos,sin,radians

n=int(input())

def koch(n):
    if n==0:
        return [[0,0],[100,0]]
    points=koch(n-1)
    new_points=[]
    for i in range(len(points)-1):
        a_x=points[i][0]
        a_y=points[i][1]
        b_x=points[i+1][0]
        b_y=points[i+1][1]
        c_x,c_y=a_x*2/3+b_x/3,a_y*2/3+b_y/3
        d_x,d_y=a_x/3+b_x*2/3,a_y/3+b_y*2/3
        e_x=(d_x-c_x)*cos(radians(60))-(d_y-c_y)*sin(radians(60))+c_x
        e_y=(d_x-c_x)*sin(radians(60))+(d_y-c_y)*cos(radians(60))+c_y
        if [a_x,a_y] not in new_points:
            new_points.append([a_x,a_y])
        new_points.append([c_x,c_y])
        new_points.append([e_x,e_y])
        new_points.append([d_x,d_y])
        if [b_x,b_y] not in new_points:
            new_points.append([b_x,b_y])
    return new_points

for i in koch(n):
    print(*i)


Measured memory_bytes: 6408
#include <iostream>
#include <string>
#define llint long long

using namespace std;

llint n, m;
string s, t;

llint gcd(llint a, llint b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}

int main(void)
{
	cin >> n >> m;
	cin >> s >> t;
	
	llint d = gcd(n, m);
	for(llint i = 0; i < d; i++){
		if(s[i*(n/d)] != t[i*(m/d)]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << n/d*m << endl;
	return 0;
}

Measured memory_bytes: 512
from collections import Counter
N, M = map(int, input().split())
class UnionFind:
    def __init__(self, n):
        self.root = [i for i in range(n)]

    def unite(self, x, y):
        if not self.same(x, y):
            self.root[self.find(y)] = self.find(x)

    def find(self, x):
        if x == self.root[x]:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)
UF = UnionFind(N)
ans = N-1
for _ in range(M):
  x, y = map(int, input().split())
  if not UF.same(x-1, y-1):
    UF.unite(x-1, y-1)
    ans -= 1
print(ans)

Measured memory_bytes: 13108
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#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
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------


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

  int n,m; cin >> n >> m;

  vector<int> t(n+1);
  vector<int> l(n+1);
  rep(i,m){
    int s;
    int c;
    cin >> s >> c;

    if(n!=1 && s==1 && c==0){
      cout << -1 <<endl;
      return 0;
    }
    if(l[s]==0){
      t[s] = c;
      l[s] = 1;
    }else{
      if(t[s]!=c){
        cout << -1 << endl;
        return 0;
      }
    }
  }

  if(n!=1 && t[1]==0){
    t[1] = 1;
  }

  rep1(i,n){
    cout << t[i];
  }

  cout << endl;


  return 0;
}


Measured memory_bytes: 256
n=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

arr2=factorization(n)
ans=0
for i in range(len(arr2)):
    count=1
    count2=1
    while arr2[i][1]>=count2:
        ans+=1
        count+=1
        count2+=count
if n==1:
    print(0)
else:
    print(ans)


Measured memory_bytes: 9516
#include <iostream>
using namespace std;
int main() {
	int a,b;
    cin >> a >> b;
    
    if (9 >= a && a >= 1 && 9 >= b && b >= 1) {
    	cout << (a*b) << endl;
    } else {
	    cout << -1 << endl;
	}
}

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

int main(){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for(int i = 0; i <= 3000; i++){
        for(int j = 0; j <= 3000; j++){
            if(n-r*i-g*j >= 0 && (n-r*i-g*j)%b == 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <vector>
using namespace std;

int N,K;

int main()
{
	scanf ("%d %d",&K,&N);

	vector<int> ans;
	if (K == 1){
		N = (N + 1) / 2;
		for (int i=0;i<N;i++) ans.push_back(1);
	}
	else if (K % 2 == 0){
		ans.push_back(K/2);
		for (int i=1;i<N;i++) ans.push_back(K);
	}
	else{
		int D = N / 2;
		for (int i=1;i<=N;i++) ans.push_back((K+1)/2);
		while (D--){
			if (ans.back() == 1){
				if (ans.back() == 1) ans.pop_back();
			}
			else{
				ans.back()--;
				while (ans.size() < N) ans.push_back(K);
			}
		}
	}

	for (int i=0;i<ans.size();i++) printf ("%d%c",ans[i],i+1<ans.size()?' ':'\n');
	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("../input.txt","r",stdin);
    int N;
    cin >> N;
    
    bool possible = false;
    while(N!=0){
        if(N%10==7){
            possible = true;
            break;
        }
        N/=10;
        
    }
    
    if(possible) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <queue>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define ll long long
#define chushihua(x,y) memset(x,y,sizeof x)
using namespace std;
const int MAXX = 100000 + 10;
const double PI = 3.14159265358979323846;
const ll mod = 1000000007;
//int main() {
//	int  t;
//	string n;
//	int a[11];
//	while (cin >> n >> t) {
//		chushihua(a);
//		int len = n.length();
//		for (int i = 0; i < t; i++) {
//			int x;
//			scanf("%d", &x);
//			a[x] = 0;
//		}
//		int pos = 0;
//		for (int i = 0; i <=9; i++) {
//
//		}
//	}
//	return 0;
//}
int main() {
	int n;
	while (cin >> n) {
		int a[100 + 10];
		ll sum = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
			sum += a[i];
		}
		//cout << sum << endl;
		int agv;
		int agv1, agv2;
		agv = sum / n;
		agv1 = sum / n + 1;
		agv2 = sum / n - 1;
		int ans1 = 0, ans2 = 0, ans3 = 0;
		for (int i = 0; i < n; i++) {
			ans1 += (abs(a[i] - agv)*abs(a[i] - agv));
			ans2 += (abs(a[i] - agv1)*abs(a[i] - agv1));
			ans3 += (abs(a[i] - agv2)*abs(a[i] - agv2));
		}
		int x = min(ans1, ans2);
		x = min(x, ans3);
		cout << x << endl;
	}
	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);

		boolean[] table = new boolean[300000];

		for (int i = 2; i < 300000; i++) {
			table[i] = true;
		}
		table[0] = false;
		table[1] = false;
		for (int i = 2; i < 300000; i++) {
			if(table[i]){
				for(int j = i+i;j<300000;j+=i)table[j]=false;
			}
		}

		while (true) {
			int n;
			int n2 = 0;

			int ncou = 0;
			int n2cou = 0;
			int sum = 0;

			// boolean flag = true;

			n = scan.nextInt();
			if (n == 0) {
				break;
			}

			n2 = n * 2;

			for (int i = 2; i < n + 1; i++) {
				if (table[i])
					ncou++;
			}

			for (int i = 2; i < n2 + 1; i++) {
				if (table[i])
					n2cou++;
			}

			// for (int i = 2; i < n + 1; i++) {
			// for (int j = 2; j < (i / 2 + 1); j++) {
			// if (i % j == 0)
			// flag = false;
			//
			// }
			// if (flag)
			// ncou++;
			// flag = true;
			//
			// }
			//
			// for (int i = 2; i < n2 + 1; i++) {
			// for (int j = 2; j < (i / 2 + 1); j++) {
			// if (i % j == 0)
			// flag = false;
			//
			// }
			// if (flag)
			// n2cou++;
			// flag = true;
			// }

			sum = n2cou - ncou;

			System.out.println(sum);
		}
		scan.close();
	}

}

Measured memory_bytes: 23548
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve 

solve :: [Int] -> Int 
solve [n, p]
    | n == 1 || p == 1 = p
    | otherwise = pf 1 [2..(truncate . sqrt $ fromIntegral p)] n p
    
pf :: Int -> [Int] -> Int -> Int -> Int
pf acc (x : xs) n p
    | p == 1 = acc
    | y == 0 = pf acc xs n q
    | otherwise = pf (acc * (x ^ y)) xs n q
    where
        y = z `div` n
        (q, z) = count p x
pf acc _ _ _ = acc 

count :: Int -> Int -> (Int, Int)
count v x = loop 0 m
    where
        m = truncate . succ . logBase (fromIntegral x) $ fromIntegral v
        loop b t
            | t - b < 2 = (v `div` bv, b)
            | v `mod` hv == 0 = loop h t
            | otherwise = loop b h
            where
                h = (b + t) `div` 2
                bv = x ^ b
                hv = x ^ h

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	bool ans;
	if(a[0] == 5 && a[1] == 5 && a[2] == 7) ans = true;
	else ans = false;
	cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int h, w;
int G[1401][1401], dp[1401][1401];

int main(){
    //freopen("in.txt", "r", stdin);
    scanf("%d %d", &h, &w);
    memset(G, 0, sizeof(G));
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<h; i++)
    for(int j=0; j<w; j++){
        scanf("%d", &G[i+1][j+1]); 
        dp[i+1][j+1] = 1 - G[i+1][j+1];
    }

    int p_edge;
    for(int i=2; i<=h; i++)
    for(int j=2; j<=w; j++){
        if(G[i][j]) continue;
        p_edge = min(dp[i-1][j], dp[i-1][j-1]);
        p_edge = min(dp[i][j-1], p_edge);
        dp[i][j] = p_edge+1;
    }

    p_edge = -1;
    for(int i=1; i<=h; i++)
    for(int j=1; j<=w; j++)
        p_edge = max(dp[i][j], p_edge);
    printf("%d\n", p_edge*p_edge);
    return 0;
}


Measured memory_bytes: 18064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);

    vector<int> vE(3);
    for(uint i=0; i<3; ++i){ cin >> vE[i]; }
    sort(vE.begin(), vE.end());
    
    cout << vE[0]*vE[1]/2 << endl;
    
    return 0;
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using vvvll = V<V<V<ll>>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vvpll = V<vpll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;
using vvch = V<vch>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a) //
#define INF 1e16
#define mod 1e9+7
/*vvll v(n,vll(m)) n行m列
A.erase(A.begin()+i); 配列Aのi番目を消せる
std::binary_search(v.bgn,v.en,a); 二分探索
abs(a,b)   pow(a,n)  to_string  stoll
auto Iter=lower_bound(v.bgn,v.en,a); v[i]>=aのv[i]
v.insert(lower_bound(v.bgn,v.en,a),b); bを入れられる
lower upper  co(*Iter) co(Iter-v.bgn) v[i]>=aのi
priority_queue<ll> pque;  pque.push(ai);
pque.top()=max(ai)  pque.pop() pque.sz
*/

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vvll g(200001,vll(0));
vll ans(200001);
vll add(200001);
void dfs(ll s,ll t){
  ans[s]+=ans[t]+add[s];
  for(ll i=0;i<g[s].sz;i++){
    if(g[s][i]!=t){
      dfs(g[s][i],s);
    }
  }
}

int main(){
  ll n,q;
  cin>>n>>q;
  ll a,b,p,x;
  FOR(i,0,n-1){
    cin>>a>>b;
    g[a].pb(b);
    g[b].pb(a);
  }
  FOR(i,0,q){
    cin>>p>>x;
    add[p]+=x;
  }
  dfs(1,0);
  FOR(i,1,n+1){
    co(ans[i]);
  }
}


Measured memory_bytes: 25856
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
    char number[1001];
    
    while(1){
        scanf("%s", number);
        int sum=0;
        if(number[0]=='0') break;
        for(int i=0; i<strlen(number); i++){
            
            sum += (number[i]-'0');
        }
    
    printf("%d\n", sum);
    
    }
    
    return 0;
    
}


Measured memory_bytes: 2672
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int c = 0;
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (scanner.nextInt() != i) {
                ans += (c + 1) / 2;
                c = -1;
            }
            c++;
        }
        System.out.println(ans + (c + 1) / 2);
    }
}

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

#define mp(x, y) make_pair(x, y)

const int maxn = 5e5 + 10;

int nex1[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}, nex2[20][2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}, {-2, -2}, {-2, -1}, {-2, 0}, {-2, 1}, {-2, 2}, {-1, 2}, {-1, -2}, {0, 2}, {0, -2}, {1, 2}, {1, -2}, {2, 2}, {2, 1}, {2, 0}, {2, -1}, {2, -2}};
int d[1005][1005];
char Map[10005][1005];
int n, m;
int check(int x, int y)
{
  if (x <= 0 || x > n || y <= 0 || y > m || Map[x][y] == '#')
    return 0;
  return 1;
}
void bfs(int a, int b)
{
  d[a][b] = 0;
  deque<pair<int, int> > que;
  que.push_back(mp(a, b));
  while (!que.empty())
  {
    int x, y;
    x = que.front().first, y = que.front().second;
    que.pop_front();
    for (int i = 0; i < 4; i++)
    {
      int _x = x + nex1[i][0], _y = y + nex1[i][1];
      if (check(_x, _y) && d[_x][_y]>d[x][y])
      {
        que.push_front(mp(_x, _y));
        d[_x][_y] = d[x][y];
      }
    }
    for (int i = 0; i < 20; i++)
    {
      int _x = x + nex2[i][0], _y = y + nex2[i][1];
      if (check(_x, _y) && d[_x][_y] > d[x][y]+1)
      {
        d[_x][_y] = d[x][y] + 1;
        que.push_back(mp(_x, _y));
      }
    }
  }
}
void init()
{
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      d[i][j] = 1e9;
}
void solve()
{
  cin>>n>>m;
  int x, y, tox, toy;
  cin>>x>>y>>tox>>toy;
  init();
  getchar();
  for (int i = 1; i <= n; i++)
    scanf("%s", Map[i] + 1);
  bfs(x, y);
  if (d[tox][toy] == 1e9)
    cout << -1 << endl;
  else
    cout << d[tox][toy] << endl;
}
signed main()
{
  solve();
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    vector<bool> used(26, false);
    bool success = true;;
    for(int i=0; i<(int)s.length(); i++){
        if(used[s[i]-'a']){
            success = false;
            break;
        }
        used[s[i]-'a'] = true;
    }
    if(success){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 256