akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    // おいしさ、ネタ
    vector<pair<ll, int>> sushi(n);
    for (int i = 0; i < n; ++i) {
        int t;
        ll d;
        cin >> t >> d;
        sushi[i] = {d, t};
    }
    sort(sushi.begin(), sushi.end(), greater<pair<ll, int>>());
    map<int, int> neta_cnt;
    ll deliciousness_base = 0;
    for (int i = 0; i < k; ++i) {
        deliciousness_base += sushi[i].first;
        ++neta_cnt[sushi[i].second];
    }
    const ll neta_base = neta_cnt.size();
    vector<pair<ll, int>> swap_target, swap_cand;
    {
        set<int> selected;
        for (int i = k; i < n; ++i) {
            if (selected.count(sushi[i].second) == 0 && neta_cnt.count(sushi[i].second) == 0) {
                swap_cand.push_back(sushi[i]);
                selected.insert(sushi[i].second);
            }
        }
        map<int, int> temp(neta_cnt);
        for (int i = k - 1; i >= 0; --i) {
            if (temp[sushi[i].second] >= 2) {
                swap_target.push_back(sushi[i]);
                --temp[sushi[i].second];
            };
        }
    }
    // swapを試していく！！
    ll ans = deliciousness_base + neta_base * neta_base;
    {
        ll diff = 0;
        for (int i = 0; i < min(swap_target.size(), swap_cand.size()); ++i) {
            diff -= swap_target[i].first;
            diff += swap_cand[i].first;
            ans = max(ans, deliciousness_base + diff + (neta_base + i + 1) * (neta_base + i + 1));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9716
N = int(input())
input_list = list(map(int, input().split()))

#num = (1 / 2) * N * (N - 1)

sum = 0
for i in range(N - 1):
    for j in range(i+1, N):
        sum += input_list[i] * input_list[j]

print(sum)


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

int main() {
	int n;
	while(cin >> n) {
		if(n==0) break;
		vector<set<int> > know(n);
		for(int i=0;i<n;i++) {
			int m;
			cin >> m;
			for(int j=0;j<m;j++) {
				int p;
				cin >> p;
				know[i].insert(p);
			}
		}int k;
		cin >> k;
		vector<int> l(k),ans;
		for(int i=0;i<k;i++)
			cin >> l[i];
		for(int i=0;i<n;i++) {
			int before = know[i].size();
			for(int j=0;j<k;j++) {
				know[i].insert(l[j]);
			}
			int after = know[i].size();
			if(before == after) {
				ans.push_back(i);
			}
		}
		if(ans.size()==1) {
			cout << 1+ans[0] << endl;
		}else
			cout << -1 << endl;
	}
}


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

int main(){
  int a[4],b[4],hit,blow,i;
	while(cin>>a[0]){
		hit=0,blow=0;
		for(i=1;i<4;i++){
			cin>>a[i];
		}
		for(i=0;i<4;i++){
			cin>>b[i];
		}
		for(i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(a[i]==b[j]){
					if(i==j)hit++;
					else blow++;
				}
			}
		}
		cout << hit << ' ' << blow << endl;
  }
	return 0;
}

Measured memory_bytes: 0
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int R;
    cin >> R;
    string ans;
    if(R < 1200){
        ans = "ABC";
    }else if(R < 2800){
        ans = "ARC";
    }else{
        ans = "AGC";
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

int main(){
	int n=read();
	int k=0,sum=0;
	while(sum<n)
		sum+=(++k);
	int dif=sum-n;
	FOR(i,1,k+1)
		if(i!=dif)
			cout<<i<<endl;
}


Measured memory_bytes: 256
#include<iostream>

int main() 
{
    int N, a100, a10, a1;
    std::cin >> N;
    int i;
    for ( i = 1; i < 10; ++i){
        if ( i*111 - N >= 0) {break;}
    }
    std::cout << i*111 << std::endl;
    return 0;
}

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

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
// constexpr ll mod = 1e9 + 7;

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

    ll ans = (N/(A+B))*A;
    if((N%(A+B))<A) {
        ans += N%(A+B);
    } else {
        ans += A;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s="";
    while(n>0)
    {
    	//cout<<n<<endl;
     if(n%26!=0)
     {
    	s.push_back((char)((n%26)+96));
    	n=n/26;
     }
    	 else
    	 {
    	 	s.push_back('z');
    	 	n=n/26;
    	 	n=n-1;
    	 //	continue;
    	 }
    //	n=n/26;
    }
    for(ll i=s.size()-1;i>=0;i--)
    cout<<s[i];
   // cout<<endl;
	return 0;
}

Measured memory_bytes: 3604
N, M = gets.split.map(&:to_i)

edges = Hash.new { |h, k| h[k] = [] }
M.times do
  a, b = gets.split.map(&:to_i)
  edges[a] << b
  edges[b] << a
end

ans = false
edges[1].each do |v1|
  ans = true if v1 == N
  edges[v1].each do |v2|
    ans = true if v2 == N
  end
end
puts ans ? "POSSIBLE" : "IMPOSSIBLE"

Measured memory_bytes: 30972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  int d,n,c=1;
  cin>>d>>n;
  fr(i,d) c*=100;
  if(n==100) cout<<101*c<<endl;
  else cout<<n*c<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main{
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35424
temp, arr = gets.chomp.split.map(&:to_i), []
n = temp.shift
n.times{|i| arr << [temp[i * 2], temp[i * 2 + 1]]}
temp = gets.chomp.split.map(&:to_i)
n = temp.shift
n.times{|i| arr << [temp[i * 2], temp[i * 2 + 1]]}
arr.sort_by!{|h, m| [h, m]}.uniq!
puts arr.map{|h, m| sprintf("%d:%02d", h, m)}.join(" ")


Measured memory_bytes: 6900
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        
        int n = Integer.parseInt(lines[0]);
        double[] x = new double[n];
        String[] u = new String[n];
        
        double ans = 0;
        double ans1 = 0;
        double ans2 = 0;
        
        for(int i=0; i<n; i++){
            String[] input = lines[i+1].split(" ");
            x[i] = Double.parseDouble(input[0]);
            u[i] = input[1];
            
            if (u[i].equals("BTC")){
                ans1 += 380000*x[i];
            }
            else if(u[i].equals("JPY")){
                ans2 += x[i]; 
            }
        }
        System.out.println(ans1+ans2);
    }
    
    private static String[] getStdin() {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> lines = new ArrayList<>();
        while (scanner.hasNext()) {
            lines.add(scanner.nextLine());
        }
        return lines.toArray(new String[lines.size()]);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


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

  int N, K, X, Y;
  cin >> N >> K >> X >> Y;

  int tot;
  if(N <= K) tot = X*N;
  else tot = X*K+Y*(N-K);

  cout << tot << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  VV<> g(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v; cin >> u >> v, --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  V<lint> a(n);
  while (q--) {
    int p, x; cin >> p >> x, --p;
    a[p] += x;
  }
  auto dfs = [&](const auto& dfs, int v, int p) -> void {
    for (int w : g[v]) if (w != p) {
      a[w] += a[v];
      dfs(dfs, w, v);
    }
  };
  dfs(dfs, 0, -1);
  for (int i = 0; i < n; ++i) {
    cout << a[i] << " \n"[i == n - 1];
  }
}

Measured memory_bytes: 21504
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100000

int parent(int);
int left(int);
int right(int);

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main()
{
  int H,i,A[MAX+1];

  scanf("%d",&H);

  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H) printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 2644
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
{
    for (int i = 0; i <= n + m - 1; i++)
    {
        for (int j = 0; j < vec.size(); j++)
        {
            int u = vec[j].second.first;
            int v = vec[j].second.second;
            int w = vec[j].first;

            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
            }
        }
    }
}
int fun(int a, int b)
{
    if (a > b)
        return 0;
    if (a == b)
        return 1;
    else
    {
        return fun(a + 1, b) + fun(a, b - a);
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    int n, m;
    cin >> n >> m;
    int arr[2 * n + 10] = {0};
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            arr[i + j]++;
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; i++)
    {
        if (m >= i && (m - i) <= 2 * n + 9)
            ans += arr[m - i];
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6000
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗を1000000007で割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= 1000000007;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= 1000000007;
	}
	return tmp;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b,a - b,a * b }) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  v1i v(5); rep(i, 5) cin >> v[i];
  rep(i, 5) if(v[i] == 0) cout << i+1 << "\n";
  return 0;
}

Measured memory_bytes: 3616
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
check=[0 for i in range(n+1)]
for i in range(m):
    check[a[i]]=1
MOD= 1000000007

c=[0]*(n+1)
c[0]=1
if 1 in a:
    c[1]=0
else:
    c[1]=1

for i in range(2,n+1):
    if check[i]!=0:
        
        continue
    else:
        c[i] = (c[i - 1] + c[i - 2]) % MOD

print(c[n])

Measured memory_bytes: 8600
package main

import (
	"fmt"
	"strings"
)

func main() {
	h := SingleInt()
	w := SingleInt()

	points := map[int]map[int]string{}
	for i := 0; i < h; i++ {
		points[i] = map[int]string{}
		str := strings.Split(SingleStr(), "")
		for idx, item := range str {
			points[i][idx] = item
		}
	}

	rowRange := []int{-1, 0, 1}
	lineRange := []int{-1, 0, 1}

	for i := 0; i < h; i++ {
		var line string
		for j := 0; j < w; j++ {
			if points[i][j] == "#" {
				line += points[i][j]
				continue
			}
			var p int
			for _, r := range rowRange {
				for _, l := range lineRange {
					if points[i+r][j+l] == "#" {
						p++
					}
				}
			}
			if p == 0 {
				line += "0"
			} else {
				line += fmt.Sprintf("%d", p)
			}

		}
		fmt.Printf("%v\n", line)
	}

}

func SingleInt() int {
	var n int
	fmt.Scan(&n)
	return n
}
func SingleStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

func ScanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 896
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDiceInLine solver = new DDiceInLine();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDiceInLine {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            double[] arr = new double[n + 1];
            double sum = 0;

            for (int i = 1; i <= n; i++) {
                arr[i] = (in.nextInt() + 1) / 2.0;
                if (i <= k) sum += arr[i];
            }

            double max = Math.max(sum, 0);
            for (int j = 1, i = k + 1; i <= n; i++, j++) {
                sum += arr[i] - arr[j];
                max = Math.max(sum, max);
            }

            out.printf("%.12f", max);
        }

    }
}



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

int main(void){
	int a, b;
	cin >> a >> b;
	if(a<=12){
		if(a<6){
			b = 0;
		}else{
			b /= 2;
		}
	}
	cout << b << endl;
	return 0;
}

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

/*int linearSearch(int x,int S[],int n){
  int i=0;
  S[n]=x;
  while(S[i]!=x){
    i++;
  }
	if(i==n)
    return -1;
  return i; 
}*/
 
int main(){
    int i,n,S[10000],q,T[10000],sum=0;
    cin>>n;
    for(i=0; i<n; i++){
        cin>>S[i];
    }
    cin>>q;
    for(i=0; i<q; i++){
        cin>>T[i];
    }
    for (int i=0;i<q;i++){
        for (int j=0;j<n;j++){
            if (T[i]==S[j]){
                sum++;
                break;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}   

Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define int long long
#define For(i,x,y) for(int i = x; i <= y; ++i)
#define FOR For
#define rev_For(i,x,y) for(int i = x; i >= y; --i)
#define REV_FOR rev_For
#define ll long long
#define Size(v) ((int)v.size())
#define _section "\n--------------------\n"
#define fi first
#define se second
#define pb push_back
using namespace std;
// using namespace __gnu_pbds;


int n;
const int nax = 1e5 + 5;
const int INF = 1e12;
int val[4];
int s[nax][4];
int dp[nax][4];

void input() {
	cin >> n;
	FOR (i, 1, n) cin >> s[i][1] >> s[i][2] >> s[i][3];

	FOR (i, 1, n) {
		FOR (j, 0, 3) {
			dp[i][j] = -1;
		}
	}
}

int calc(int i, int v) {
	if (dp[i][v] != -1) return dp[i][v];
	if (i > n) return -INF;

	if (i <= 0) return 0;

	bool used[4];
	FOR (j, 0, 3) used[j] = false;
	used[v] = true;

	int ret = -INF;

	for (int j = 1; j <= 3; ++j) {
		if (!used[j]) {
			ret = max(ret, calc(i - 1, j) + s[i][v]);
		}
	}

	return (dp[i][v] = ret);
}

int maxi(int a, int b, int c) {
	return max(a, max(b, c));
}

void solve() {
	cout << maxi(calc(n, 1), calc(n, 2), calc(n, 3));
	// cout << calc(0, )
}

signed main() {
#ifdef _DEBUG
	// freopen("INPUT.inp", "r", stdin);
	//freopen("OUTPUT.out", "w", stdout);
	clock_t start, end;
	start = clock();
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//------------------------------------------------------------------------------------
//----------------------------------MAIN PROGRAM--------------------------------------
	int t = 1;
	while (t--) {
		input();
		solve();
	}
//--------------------------------------END-------------------------------------------
//------------------------------------------------------------------------------------
#ifdef _DEBUG
	end = clock();
	cerr << "\n----------\nTime Elapsed: " << fixed << double(end - start) / double(CLOCKS_PER_SEC) << setprecision(6) << '\n';
#endif
	return 0;
}

Measured memory_bytes: 14336
use text_io::*;

fn main() {
    let n: usize = read!();
    let mut v = Vec::new();
    for _ in 0..n {
        let a: usize = read!();
        v.push(a);
    }
    let mut a:usize = 0;
    let mut c:usize = 0;
    let mut kabu:usize = 0;
    let mut have:usize = 1000;
    for i in 0..n-1 {
        if a==0 {
            if v[i]<v[i+1] {
                kabu = have/v[i];
                have %= v[i];
                a = 1;
                c = i;
            }
        }
        else if a==1 {
            if v[i]>v[i+1] {
                have = have+v[i]*kabu;
                kabu = 0;
                a = 0;
            }
        }
    }
    if v[c]>v[n-1] {
        println!("{}",have+(kabu*v[c]));
    }
    else {
        println!("{}",have+(kabu*v[n-1]));
    }
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vecl A(N); REP(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    bool ok = true;
    REP(i,N) {
        if(A[i]%2 != 0) ok = false;
    }
    cout << (ok ? "second" : "first") << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 100005
#define M 105
using namespace std;
int n,m,c,a[M];
void GG(){ printf("Impossible"); exit(0);}
int main()
{
	int i;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++)
		scanf("%d",&a[i]),c+=(a[i]&1);
	if(n==1){ printf("1\n1\n1"); return 0;}
	if(m==1){
			printf("%d\n2\n%d %d",n,1,n-1);
			return 0;
		  }
	if(n%2==1&&c>1) GG();
	if(n%2==0&&c>2) GG();
	sort(a+1,a+m+1);
	if(n%2==0&&c==2){
		for(i=1;i<=n;i++) if(a[i]&1) break;
		while(i>1) swap(a[i],a[i-1]),i--;
		for(i=2;i<=n;i++) if(a[i]&1) break;
		while(i<m) swap(a[i],a[i+1]),i++;
	  }
	if(n&1){
		for(i=1;i<=n;i++) if(a[i]&1) break;
		while(i>1) swap(a[i],a[i-1]),i--;
	  }
	for(i=1;i<=m;i++) printf("%d ",a[i]);
	a[1]--,a[m]++;
	printf("\n%d\n",m-(a[1]==0));
	for(i=1;i<=m;i++)
		if(a[i]) printf("%d ",a[i]);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long Q,H,S,D,N,ans;
int main(){
    cin>>Q>>H>>S>>D>>N;
    ans=(N%2==0)?(min(min(min(Q*8,H*4),S*2),D)*N/2):(min(min(Q*4,H*2),S)+min(min(min(Q*8,H*4),S*2),D)*(N-1)/2);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
//#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 2e3+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

#define int ll
int k,a[MAX_N];
int get(int x,int y){
    if(x%y==0)
        return x/y;
    return x/y+1;
}
#define sz(vec) int(vec.size())
bool mark[MAX_N*MAX_N];
main(){
    fast();per(0);
    //get_fact();
    int n;cin>>n;
    int tot=0;
    for(int i=1;i<=n;i++)
        cin>>a[i],tot+=a[i];
    sort(a+1,a+n+1);
    vector<int> vec={0};
    for(int i=1;i<=n;i++){
        for(int j=sz(vec)-1;j>=0;j--){
            int jj=vec[j];
            int t=a[i]+jj;
            if(!mark[t])
                vec.pb(t),
                mark[t]=1;
        }
    }
    int minn=-1;
    tot=get(tot,2);
    for(int i:vec)
        if(i>=tot){
            if(minn==-1)
                minn=i;
            minn=min(minn,i);
        }
    cout<<minn;
}



Measured memory_bytes: 20968
#include <iostream>
#include <sstream>
#include <fstream>

#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cctype>

#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
        os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

struct E {
    int d,p;
};

void solve(int n, int m, vector<E>& es){
    int total = 0;
    rep(i,n) total += es[i].d*es[i].p;
    sort(all(es), [](const E& a, const E& b){
            return a.p > b.p;
        });

    int sum=0;
    rep(i,n){
        int take = min(m, es[i].d);
        sum += es[i].p*take;
        m -= take;
        if(m==0) break;
    }

    cout << total-sum << endl;
}

int main(){
    int n,m;
    while(cin>>n>>m, n!=0 || m!=0){
        vector<E> es(n);
        rep(i,n){
            scanf("%d %d", &es[i].d, &es[i].p);
        }
        solve(n,m,es);
    }
}

Measured memory_bytes: 1328
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
const int INF=1000000007;

int main (void){
    int n,i,p[11],sum=0;
    cin >> n;
    for(i=0;i<n;i++) {
    	cin >> p[i];
    	sum+=p[i];
    }
    sort(p,p+n);
    cout << sum-p[n-1]/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

int main() {
    ll N,M;
    cin >> N >> M;
    auto A = InputVec(N);
    auto B = InputVec(M);
    auto sA = A;
    auto sB = B;
    sort(sA.begin(),sA.end());
    sort(sB.begin(),sB.end());
    set<ll> s;
    for (int i = 0; i < N; ++i) {
        if(s.find(A[i]) != s.end()){
            cout << "0" << endl;
            return 0;
        }
        s.insert(A[i]);
    }
    s.clear();
    for (int i = 0; i < M; ++i) {
        if(s.find(B[i]) != s.end()){
            cout << "0" << endl;
            return 0;
        }
        s.insert(B[i]);
    }
    ll count = 1;
    ll MOD = 1000000007;
    for (int i = 1; i <= N * M; ++i) {
        ll currentX;
        ll currentY;
        bool isExistX = binary_search(sA.begin(),sA.end(),i);
        bool isExistY = binary_search(sB.begin(),sB.end(),i);
        currentX = distance(lower_bound(sA.begin(),sA.end(),i),sA.end());
        currentY = distance(lower_bound(sB.begin(),sB.end(),i),sB.end());
        //cout << currentX<<":" << currentY << endl;
        if(isExistX && isExistY){

        }else{
            if(isExistX){
                count *= currentY;
                count %= MOD;
            }else if(isExistY){
                count *= currentX;
                count %= MOD;
            }else{
                ll tmp = currentX * currentY -(N * M - i);
                count = count * tmp % MOD;
            }
        }
    }
    cout << count << endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,a[110],cnt=0;
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>a[i];
		if(a[i]!=i)
			cnt++;
	}
	if(cnt<=2)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    H=LI()
    adj=[[]for _ in range(N)]
    for i in range(M):
        a,b=MI()
        a-=1
        b-=1
        adj[a].append(b)
        adj[b].append(a)
        
    used=[0]*N
    Hi=[[0,0]for _ in range(N)]
    for i in range(N):
        Hi[i][0]=H[i]
        Hi[i][1]=i
        
    Hi.sort(reverse=True)
    
    ans=0
    for i in range(N):
        v=Hi[i][1]
        HH=Hi[i][0]
        if used[v]==0:
            temph=0
            used[v]=1
            for nv in adj[v]:
                temph=max(H[nv],temph)
                used[nv]=1
            if HH>temph:
                ans+=1
                
    print(ans)
        
    

main()


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

int main() {
	set<string> s;
	int n;
	string temp;
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++) {
		getline(cin, temp);
		s.insert(temp);
	}
	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 19068
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 200005
const ll mod = 1000000007;
ll modpow(ll x,ll y){
  ll res = 1;
  while(y){
    if(y & 1) res = res * x % mod;
    y >>= 1;
    x = x * x % mod;
  }
  return res;
}
int n;
ll c[maxn];
int main(){
  n = getint();
  for(int i = 1;i <= n;i++) c[i] = getll();
  if(n == 1){
    putll((c[1] + c[1]) % mod,'\n');
    bufo.flush();
    return 0;
  }
  sort(c + 1,c + n + 1);
  ll ans = 0;
  for(int i = 1;i <= n;i++)
    (ans += modpow(2,n - 2) * (n - i + 2) % mod * c[i]) %= mod;
  (ans *= modpow(2,n)) %= mod;
  putll(ans,'\n');
  bufo.flush();
  return 0;
}


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

int main() {
    ll k;
    std::cin >> k;
    string s;
    std::cin >> s;
    if(s.size()<=k){
        std::cout << s << std::endl;
    }else{
        std::cout << s.substr(0,k)+"..." << std::endl;
    }
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int c[3];
  while(cin>>c[0]){
    FOR(i,1,3)cin>>c[i];
    int rest = 20-c[0]-c[1];
    REP(i,3){
      if(20-c[0]-c[1]>=c[i]) rest--;
    }
    if(rest>=4) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <tuple>
#include <cassert>
using namespace std;

const int INF = 1 << 29;

int min_cost_from(const int state, const int crrnt_nd, const int source,
                  vector< vector<int> > &dpTable,
                  const vector< vector< pair<int, int> > > &adjList)
{
  int n_nodes = adjList.size();
  
  // Already Visited
  if (dpTable[state][crrnt_nd] >= 0) {
    return dpTable[state][crrnt_nd];
  }
  
  // Case: dp[V][src] = 0
  if (state == (1 << n_nodes) - 1 && crrnt_nd == source) {    
    return dpTable[state][crrnt_nd] = 0;
  }

  // Case: dp[S][v] = min{dp[S+{u}][u]+d[v, u]; u not in S}
  int tmp_min = INF;
  for (auto itr = adjList[crrnt_nd].begin(); itr != adjList[crrnt_nd].end(); ++itr) {
    int next_nd, dist;
    tie(next_nd, dist) = *itr;
    // For "next_nd" not in "state"
    if (!(state >> next_nd & 1)) {
      int next_state = state | 1 << next_nd;
      int cost_from_next = min_cost_from(next_state, next_nd, source, dpTable, adjList);
      tmp_min = min(tmp_min, cost_from_next + dist);
    }
  }
  return dpTable[state][crrnt_nd] = tmp_min;
}

int held_karp(const vector< vector< pair<int, int> > > &adjList, int source)
{
  int n_nodes = adjList.size();
  vector< vector<int> > dpTable(1 << n_nodes, vector<int>(n_nodes, -1));
  int empty_set = 0;
  int cost =  min_cost_from(empty_set, source, source, dpTable, adjList);
  return cost < INF ? cost: -1;
}

void print_adjacency_list(const vector< vector< pair<int, int> > > &adjList)
{
  for (int s = 0; s < adjList.size(); ++s) {
    cout << s << ":";
    for (auto itr = adjList[s].begin(); itr != adjList[s].end(); ++itr) {
      int t, d;
      tie(t, d) = *itr;
      cout << " (" << t << ", " << d << ")";
    }
    cout << endl;
  }
}

int main(int argc, char *argv[])
{
  int n_nodes;
  int n_links;
  cin >> n_nodes >> n_links;
  vector< vector< pair<int, int> > > adjList(n_nodes);
  for (int i = 0; i < n_links; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    adjList[s].push_back(make_pair(t, d));
  }

  // print_adjacency_list(adjList);
  cout << held_karp(adjList, 0) << endl;
  
  return 0;
}

Measured memory_bytes: 6128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	int a[5];
	int i,j,temp;

	while(scanf("%d,%d,%d,%d,%d",a,a+1,a+2,a+3,a+4)!=EOF){
		for(i=4;i>=1;i--)
			for(j=0;j<i;j++)
				if(a[j]>a[j+1]){
					temp=a[j];
					a[j]=a[j+1];
					a[j+1]=temp;
				}
		if(a[1]==a[2]&&a[2]==a[3]&&(a[0]==a[1]||a[3]==a[4]))
			printf("four card\n");
		else if((a[0]==a[1]&&a[1]==a[2]&&a[3]==a[4])||(a[0]==a[1]&&a[2]==a[3]&&a[3]==a[4]))
			printf("full house\n");
		else if(a[1]+1==a[2]&&a[2]+1==a[3]&&a[3]+1==a[4]&&( a[0]+1==a[1] || (a[0]==1&&a[4]==13) ))
			printf("straight\n");
		else if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3])||(a[2]==a[3]&&a[3]==a[4]))
			printf("three card\n");
		else if((a[0]==a[1]&&a[2]==a[3])||(a[0]==a[1]&&a[3]==a[4])||(a[1]==a[2]&&a[3]==a[4]))
			printf("two pair\n");
		else if(a[0]==a[1]||a[1]==a[2]||a[2]==a[3]||a[3]==a[4])
			printf("one pair\n");
		else
			printf("null\n");
	}	
	return 0;
}

Measured memory_bytes: 580
#include<stdio.h>

int main(){
  int A, B;
  scanf("%d %d", &A, &B);
  
  if(A <= 8 && B <= 8){
    printf("Yay!\n");
    return 0;
  }else{
    printf(":(\n");
    return 0;
  }
  return 0;
}

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

int main() {
 int N;
 cin >> N;
 int A = N / 1000;
 int B = (N % 1000) / 100;
 int C = (N % 100) / 10;
 int D = N % 10;

 

 if(A + B + C + D == 7) {
   cout << A << '+' << B << '+' << C << '+' << D << "=7" << endl;
 }else if(A + B + C - D == 7) {
   cout << A << '+' << B << '+' << C << '-' << D << "=7" << endl;
 }else if(A + B - C - D == 7) {
   cout << A << '+' << B << '-' << C << '-' << D << "=7" << endl;
 }else if(A - B - C - D == 7) {
   cout << A << '-' << B << '-' << C << '-' << D << "=7" << endl;
 }else if(A - B + C + D == 7) {
   cout << A << '-' << B << '+' << C << '+' << D << "=7" << endl;
 }else if(A - B - C + D == 7) {
   cout << A << '-' << B << '-' << C << '+' << D << "=7" << endl;
 }else if(A - B + C - D == 7) {
   cout << A << '-' << B << '+' << C << '-' << D << "=7" << endl;
 }else if(A + B - C + D == 7) {
   cout << A << '+' << B << '-' << C << '+' << D << "=7" << endl;
 }

}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * 提出
	 *
	 */

	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = 0;
		int b = 0;
		int c = 0;
		int tmpB = 0;
		int tmpC = 0;

		/* ３つの整数を読み込み、それらを値が小さい順に並べて出力するプログラムを作成する */
		a = scanner.nextInt();
		b = scanner.nextInt();
		c = scanner.nextInt();

		if (a > b) {
			tmpB = b;
			b = a;
			a = tmpB;
		}
		if (b > c) {
			tmpC = c;
			c = b;
			b = tmpC;
		}
		if (a > b) {
			tmpB = b;
			b = a;
			a = tmpB;
		}

		System.out.println(a + " " + b + " " + c );

	}
}



Measured memory_bytes: 26148
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n=list(input())
    if '7' in n:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()



Measured memory_bytes: 61624
N,S = map(int,input().split())
X = list(map(int,input().split()))

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

new_X = []
for x in X:
    new_X.append(abs(S-x))

ans = new_X[0]
for x in new_X:
    ans = min(ans,gcd(ans,x))
print(ans)

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

int main(void){
  int x,i,j;

  if(scanf("%d",&x)==1){}

  for(i=-1000;i<1000;i++){
    for(j=-1000;j<1000;j++){
      if(pow((double)i,5.0)-pow((double)j,5.0)==(double)x){
	printf("%d %d\n",i,j);
        return 0;
      }
    }
  }
  
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<float> A(N);
  for(int i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  
  float count = 0;
  for(int i = 0; i < N; ++i) {
    count += 1 / A.at(i);
  }
  
  cout << 1 / count << endl;
}


Measured memory_bytes: 256
while True:
    try:
        W = float(input())
        if W <= 48:
            print("light fly")
        elif W <= 51:
            print("fly")
        elif W <= 54:
            print("bantam")
        elif W <= 57:
            print("feather")
        elif W <= 60:
            print("light")
        elif W <= 64:
            print("light welter")
        elif W <= 69:
            print("welter")
        elif W <= 75:
            print("light middle")
        elif W <= 81:
            print("middle")
        elif W <= 91:
            print("light heavy")
        else:
            print("heavy")
    except EOFError:
        break
            

Measured memory_bytes: 7236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int total, leg; cin >> total >> leg;
    bool exist = false;
    rep(i, total+1){
        if(i*2 + (total - i)*4 == leg) exist = true;
    }
    if(exist) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
set_v=set(v)
if len(set_v)==1:
    print(n//2)
    exit()
a=Counter(v[::2]).most_common() #(数字,何回出現)が出現回数が大きい方から
b=Counter(v[1::2]).most_common()
if a[0][0]==b[0][0]:
    print(min(n-b[0][1]-a[1][1],n-a[0][1]-b[1][1]))
else:
    print(n-a[0][1]-b[0][1])

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

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

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,i; cin >> N >> i;
    cout << N+1-i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    int n, m;
    cin >> n >> m;
    int x[m];
    for (int i = 0; i < m; i++) cin >> x[i];
    sort(x, x+m);

    int d[m];
    for (int i = 0; i < m - 1; i++){
        d[i] = x[i+1] - x[i];
    }
    sort(d, d+m-1);

    int ans = 0;
    for (int i = 0; i < m - n; i++){
        ans += d[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n = int(input())
s = input()
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p",
            "q","r","s","t","u","v","w","x","y","z"]
ans = 0
for i in range(1,n-1):
    x = s[:i]
    y = s[i:]
    comp = 0
    for j in alphabet:
        if j in x and j in y:
            comp += 1
    if comp > ans:
        ans = comp
print(ans)        

Measured memory_bytes: 65108
N=int(input())
T=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
H=[0 for i in range(N)]
P=10**9+7
#fixed-->1
B=[0 for i in range(N)]
C=[0 for i in range(N)]
for i in range(N):
    if i==0:
        B[i]=1
    else:
        if T[i-1]<T[i]:
            B[i]=1
for i in range(N)[::-1]:
    if i==N-1:
        C[i]=1
    else:
        if A[i+1]<A[i]:
            C[i]=1
ans=1
for i in range(N):
    if B[i]==1 and C[i]==1:
        if A[i]!=T[i]:
            ans*=0
    elif B[i]==1 and C[i]==0:
        if T[i]>A[i]:
            ans*=0
    elif B[i]==0 and C[i]==1:
        if A[i]>T[i]:
            ans*=0
    else:
        ans*=min(T[i],A[i])
        ans%=P
print(ans)

        
        

Measured memory_bytes: 18624
function main(input) {
    var a = input[0].split(" ").map(v=>v-0);
    var ans = false;
    if(Math.abs(a[0]-a[1]) <= a[3] && Math.abs(a[1]-a[2]) <= a[3]) ans = true;
    if(Math.abs(a[0]-a[2]) <= a[3] ) ans = true;
    console.log(ans?"Yes":"No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7500
#include <iostream>
using namespace std;
int main(void) {
  string s;
  string a[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cin >> s;
  int idx;
  for (int i = 0; i < 7; i++) {
    if (s == a[i])
      idx = i;
  }
  cout << 7 - idx << endl;
}

Measured memory_bytes: 256