akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;

vector<ll> sum_list;

ll bit_count(ll a){
    ll ret = 0;
    for(ll x : sum_list){
        if((x & a) == a) ret++;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];
    
    REP(i,N){
        ll sum = 0;
        for(int j=i;j<N;j++){
            sum += a[j];
            if(sum != 0) sum_list.push_back(sum);
        }
    }
    
    ll mask = 0;
    for(ll i=40;i>=0;i--){
        if(bit_count(mask | (1LL<<i)) >= K) mask |= (1LL << i);
    }
    cout << mask << endl;
}

Measured memory_bytes: 6384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  ll k; cin >> k; ll ans = 0;
  
  queue<ll> q;
  
  rep(i,9) q.push(i+1);
  
  while(k != 0){
    ll now = q.front();
    k--;
    q.pop();
    
    if(k == 0){
      ans = now;
      break;
    }
    
    ll per = now % 10;
    
    if(per != 0){
      q.push(now*10 + per-1);
    }
    q.push(now*10 + per);
    if(per != 9){
      q.push(now*10 + per+1);
    }
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,x,y,s=0;
	scanf("%d%d%d%d",&n,&k,&x,&y);
	if(n>k){
		s=s+(k*x);
		n-=k;
		s=s+(n*y);
	} 
	else{
		s=s+(n*x);
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;++i)
		ans+=(i+ n/i*i) *(n/i) / 2 ;
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 3612
fun main(args: Array<String>) {
    val(a,b)= readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!
    if( s[a]=='-' && '-' !in s.take(a) && '-' !in s.takeLast(b)){
        println("Yes")
    }else{
        println("No")
    }
}

Measured memory_bytes: 37872
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

vector<int> v[3], sum[3];

vector<int> solve(int N) {
	vector<int> res;
	
	if (N == 3) {
		res.assign({2, 5, 63});
		return res;
	}
	
	REP(i, 3) {
		sum[i] = v[i];
		FOR(j, 1, v[i].size()) sum[i][j] += sum[i][j - 1];
	}
	
	REP(a, v[0].size() + 1) {
		REP(b, v[1].size() + 1) {
			int c = N - a - b;
			if (c > v[2].size()) continue;
			if (c < 0) break;
			if ((a > 0) + (b > 0) + (c > 0) <= 1) continue;
			
			int sa = a ? sum[0][a - 1] : 0;
			int sb = b ? sum[1][b - 1] : 0;
			int sc = c ? sum[2][c - 1] : 0;
			
			if (a > 0 && (sb + sc) % 2 != 0) continue;
			if (b > 0 && (sa + sc) % 3 != 0) continue;
			if (c > 0 && (sa + sb) % 5 != 0) continue;
			res.insert(res.end(), v[0].begin(), v[0].begin() + a);
			res.insert(res.end(), v[1].begin(), v[1].begin() + b);
			res.insert(res.end(), v[2].begin(), v[2].begin() + c);
			return res;
		}
	}
	
	return res;
}

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

bool check(int N, vector<int> ans) {
	if (ans.size() != N) { puts("A"); return false; }
	set<int> ss;
	REP(i, N) ss.insert(ans[i]);
	if (ss.size() != ans.size()) { puts("B"); return false; }
	
	
	REP(i, N) if (ans[i] < 1 || ans[i] > 30000) { puts("C"); return false; }
	
	int g = ans[0];
	REP(i, N) g = gcd(g, ans[i]);
	if (g != 1) { puts("D"); return false; }
	
	int sum = accumulate(ans.begin(), ans.begin() + N, 0);
	REP(i, N) if (gcd(ans[i], sum - ans[i]) == 1) {
		puts("E");
		printf("%d %d\n", ans[i], sum - ans[i]);
		return false;
	}
	
	return true;
}

int main() {
	int N; cin >> N;
	
	int mx = 30000;
	for (int i = 2; i <= mx; i += 2) v[0].push_back(i);
	for (int i = 3; i <= mx; i += 6) v[1].push_back(i);
	for (int i = 5; i <= mx; i += 5) if (i % 2 && i % 3) v[2].push_back(i);
	
	vector<int> ans = solve(N);
	if (ans.empty()) assert(false);
	
	//FOR(i, 3, 20000) if (!check(i, solve(i))) cout << i << endl;
	REP(i, N) printf("%d%c", ans[i], i == N - 1 ? '\n' : ' ');
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int a,b,c;
int main()
{
    a=read(),b=read();c=6-a-b;cout<<c<<"\n";
	return 0;
}


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

using namespace std;

using Bs = bitset<10010>;

void solve() {
    int n; cin >> n;
    Bs b; b[0] = 1;
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        b |= b<<x;
    }
    int res = 0;
    for (int i = 0; i <= 10000; i++) {
        if (i%10==0 || !b[i]) continue;
        res = max(res, i);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#include "math.h"
int n;
void dfs(string s , char mx){
    if(s.size() == n){
        cout << s << endl;
        return;
    }

    for(char c = 'a'; c <= mx+1; c++){
        string t;
        t = s;
        t += c;
        dfs(t, max(mx, c));
    }
}
int main(){
    cin >> n;

    dfs("", 'a'-1);
}

Measured memory_bytes: 1536
#include<cstdio>
#include <algorithm>
#include <istream>
#include <stdio.h>
#include <iostream>
using namespace std;

int a, b;
string s, t, w;

int main()
{
	cin >> s >> t >> a >> b >> w;
	if ( w == s ) { a--;}
	else b--;
	cout << a << " " << b;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define R register
using namespace std;
int A[100010],n,K,Q;
int main()
{
	scanf("%d%d%d",&n,&K,&Q);
	for(R int i = 1; i <= n; i++) A[i] = Q;
	while(Q--){
		int w; scanf("%d",&w); A[w]--;
	}
	for(R int i = 1; i <= n; i++){
		if(A[i] >= K) puts("No");
		else puts("Yes");
	}
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ll n,error=0;
	cin >> n;
	ll f[10005];
	memset(f,0,sizeof(f));
	for(ll i=1;i<=100;i++){
		for(ll j=1;j<=100;j++){
			for(ll k=1;k<=100;k++){
				ll x=i*i+j*j+k*k+i*j+i*k+j*k;
				if(x<=10000){
					f[x]++;
				}
			}
		}
	}
	for(ll i=1;i<=n;i++){
		cout << f[i] << endl;
	}
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    cout << pow(n, 3) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();

        int index = S.length() - T.length();
        while (index >= 0) {
            int j;
            for (j = 0; j < T.length(); j++) {
                if (S.charAt(index + j) != T.charAt(j) && S.charAt(index + j) != '?'){
                    break;
                }
            }
            if (j == T.length()) {
                break;
            }
            index--;

        }
        if (index < 0) {
            System.out.println("UNRESTORABLE");
            return;
        }

        char[] c = S.toCharArray();
        for (int i = 0; i < T.length(); i++) {
            c[index + i] = T.charAt(i);
        }
        for (int i = 0; i < c.length; i++) {
            if (c[i] == '?') {
                c[i] = 'a';
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

int N,c[1000000];

int main(){
	cin>>N;
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			for(int k=1;k<=100;k++){
				c[i*i+j*j+k*k+i*j+j*k+k*i]++;
			}
		}
	}
	for(int i=1;i<=N;i++){
		cout<<c[i]<<endl;
	}
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
int main(){
    ll q,h,s,d,sum,ans=0;
    cin >> q >> h >> s >> d >> sum;
    h = min(h,2*q);
    s = min(s,2*h);
    d = min(d,2*s);
    ans += (sum/2)*d;
    sum %= 2;
    ans += sum*s;
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define booga cout << "booga" << endl
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

void testcase(){

}

int main(int argc, char** argv){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,h[100005];
	cin >> n;
	for(int i{0};i < n;i++){
		cin >> h[i];
	}
	for(int i{n-1};i >= 1;i--){
		if(h[i-1] - h[i] > 1){
			cout << "No \n";
			return 0;
		}
		if(h[i-1] - h[i] == 1){
			h[i-1]--;
		}
	}
	cout << "Yes \n";
	return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int n;
	cin>>n;
	map<long long int,long long int> m;
	set<long long int> s;
	while(n--){
		long long int x;
		cin>>x;
		s.insert(x);
		m[x]++;
	} 
	set<long long int>::iterator it;
	long long int ans=0;
	for(it=s.begin();it!=s.end();it++){
		if(m[*it]<*it){
			ans+=m[*it];
		}
		else if(m[*it]>*it){
			ans+=m[*it]-*it;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 14056
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

const int N = 200001;
int i, j, k, m, n;
string s;
int a[N];

ll A, B;
ll dp[5][N];

int cost(int stage, int v) {
   if (stage == 0 || stage == 4) return v;
   if (stage == 1 || stage == 3) {
       if (v == 0) return 2;
       return v % 2;
   }
   return (v + 1) % 2;
}

void upd(ll& x, ll y) {
    if (x == -1 || x > y) x = y;
}

void solve() {
    F0(i, n) cin >> a[i];
    ll ans = 0;

    CL(-1, dp);
    dp[0][0] = 0;
    F0(j, 5) F0(i, n) if (dp[j][i] != -1) {
        upd(dp[j][i + 1], dp[j][i] + cost(j, a[i]));
        if (j + 1 < 5) upd(dp[j + 1][i], dp[j][i]);
    }
    ans = -1;
    F0(j, 5) if (dp[j][n] != -1) upd(ans, dp[j][n]);
    cout << ans << endl;
}

int main() {
    //freopen("x.in", "r", stdin);
    while (cin >> n) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 8832
#include <stdio.h>
#define N 2005
typedef long long ll;
int n,x,d[N*2],f[N][N];
inline int min(int a,int b){return a<b?a:b;}
int main() {
	scanf("%d%d",&n,&x);
	int* const a=d+n;
	for(int i=0;i<n;++i) scanf("%d",d+i),a[i]=d[i];
	for(int i=0;i<n;++i) {
		f[i][0]=a[i];
		for(int j=1;j<n;++j) f[i][j]=min(f[i][j-1],a[i-j]);
	}
	ll ans=1LL<<60,tmp;
	for(int j=0;j<n;++j) {
		tmp=(ll)j*x;
		for(int i=0;i<n;++i) tmp+=f[i][j];
		if(tmp<ans) ans=tmp;
	}
	printf("%lld",ans);
	return 0;
}

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

int main() {
  string S,T;
  cin >> S >> T;
  bool res = true;
  for(int i=0;i<S.size();i++){
    if(S[i] != T[i]){
      res = false;
      break;
    }
  }
  if(res ){
    cout << "Yes";
  }else{
    cout << "No";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3132
import kotlin.math.sqrt

fun main() {
//    a()
    b()
}

fun b() {
    val (n, d) = readLine()!!.split(" ").map(String::toInt)
    var result = 0
    for (i in 0 until n) {
        val (x, y) = readLine()!!.split(" ").map(String::toDouble)
        if (d >= sqrt(x * x + y * y)) result++
    }
    println(result)
}

fun a() {
    val x = readLine()!!.toInt()
    if (x >= 30) {
        println("Yes")
    } else {
        println("No")
    }
}





Measured memory_bytes: 60520
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;


int main(){
    int n; cin >> n;
    vector<vector<P>> vec;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        vector<P> v;
        for(int i=0;i<a;i++){
            int x,y; cin >> x >> y;
            v.push_back(P(x-1,y));
        }
        vec.push_back(v);
    }
    //bit全探索
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        bool ok=true;
        int cnt=0;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                cnt++;
                for(int k=0;k<vec[j].size();k++){
                    if(vec[j][k].second==1){
                        if((i&(1<<vec[j][k].first))==0){ok=false;break;}
                    }else{
                        if((i&(1<<vec[j][k].first))!=0){ok=false;break;}
                    }
                }
            }
            if(!ok) break;
        }
        //cout << i << " " << ok << " " << cnt << endl;
        if(ok) ans=max(ans,cnt);

    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())

A = [[] for _ in range(n)]
C = [0] * n

for i in range(n):
    c_as = list(map(int, input().split()))
    C[i], A[i] = c_as[0], c_as[1:]

INF = 10 ** 9
ans = INF

for s in range(1<<n):
    smart = [0] * m
    cost_sum = 0
    for i in range(n):
        if (s >> i) % 2 == 0: continue
        cost_sum += C[i]
        for j in range(m):
            smart[j] += A[i][j]

    ok = True
    for i in range(m):
        if x > smart[i]:
            ok = False
    
    if ok:
        ans = min(ans, cost_sum)

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


Measured memory_bytes: 9132
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N;
vector<int> g[10010];

vector<ll> C;
vector<int> in;
vector<pair<int,int>> edges;

bool used[10010];
int num;
vector<ll> ans;
ll M;

vector<ll> fin;
ll fM;

void dfs(int now){
  used[now]=true;
  for(int i=0;i<g[now].size();i++){
      int nex=g[now][i];
      if(used[nex]) continue;

      dfs(nex);
      //M+=ans[nex];
  }
  ans[now]=C[num];
  num++;
  used[now]=false;
  return;
}

int main(){
  cin>>N;
  C.resize(N);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    edges.push_back(make_pair(a,b));
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int i=0;i<N;i++) cin>>C[i];

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

  ans.resize(N,0);
  /*fin.resize(N,0);
  for(int i=0;i<N;i++){
      dfs(i);
      if(fM<M){
          fM=M;
          fin=ans;
      }
      M=0;
      num=0;
  }*/
  int start=0;
  for(int i=0;i<N;i++){
      if(g[i].size()>1) start=i;
  }
  dfs(start);

  //cout<<fM<<endl;
  for(int i=0;i<edges.size();i++){
      M+=min(ans[edges[i].first],ans[edges[i].second]);
  }
  cout<<M<<endl;
  for(int i=0;i<N;i++) cout<<ans[i]<<" ";
  cout<<endl;
  

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int ans=0;
	string s,t;
	cin>>s>>t;
	rep(i,3){
		if(s[i]==t[i])ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
t_before = 0
x_before = 0
y_before = 0

travel_list = [map(int, input().split()) for _ in range(N)]

def judge(t_plus, x_diff, y_diff):
    distance = abs(x_diff) + abs(y_diff)
    if (t_plus % 2) != (distance % 2):
        return False
    if distance > t_plus:
        return False 
    return True

is_found = False

for i in range(N):
    t, x, y = travel_list[i]
    result = judge(t_plus=t-t_before, x_diff=x-x_before, y_diff=y-y_before)
    if result:
        t_before = t
        x_before = x
        y_before = y
    else:
        break
else:
    is_found = True
if is_found:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 52300
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (ll i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
//typedef std::pair<int,int> P;

    ll N;
    ll a,b,c,x,y;
    ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>a>>b>>c>>x>>y;
    cout<<
      (c*2<a+b?c*2:(a+b))*min(x,y)+abs(x-y)*min((x>y?a:b),c*2);
    
    return 0;
}


Measured memory_bytes: 256
ticket = input()
A,B,C,D = [n for n in ticket]
for i in range(2**3):
  answer = int(ticket[0])
  op = ["-","-","-"]
  for j in range(3):
    if (i>>j)&1 == 1:
      answer += int(ticket[j+1])
      op[j] = "+"
    else:
      answer -= int(ticket[j+1])
  if answer == 7:
    result = A + op[0] + B + op[1] + C + op[2] + D + "=7"
    break
print(result)

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

int main() {
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for (int i = 0; i < n; i++)
        cin >> t[i];

    sort(t.begin(), t.end());
    int ans = 0;
    for (int i = 0; i < n;) {
        int j = i + 1;
        int person = 1;
        ans++;
        while (person < c && t[i] + k >= t[j]) {
            person++;
            j++;
        }
        i = j;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
//B - Two Anagrams: 8Min;
//Assunto: String;
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s, t;
    bool g;
    cin >> s >> t;
    sort(all(s)); sort(rall(t));
    if(s.size() < t.size() and s <= t.substr(0, s.size())) cout << "Yes\n";
    else if(s < t) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
using namespace std;

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int main(){
	int n;
	while(cin >> n) {
		map<int,int> has;
		int a;
		rep(i,0,n) {
			cin >> a;
			has[a]++;
		}
		int ans = 0;
		foreach(has, itr) {
			if(itr->second % 2 != 0) ans++;
		}
		cout << ans << endl;
	}
    return 0;
}


Measured memory_bytes: 4992
N = gets.to_i
csfs = (N - 1).times.map { gets.split.map(&:to_i) }
csfs.each.with_index do |(c, s, _), i|
  ans = s + c
  ((i + 1)...(csfs.size)).each do |j|
    c, s, f = csfs[j]
    if s > ans
      ans = s + c
    elsif (ans - s) % f == 0
      ans += c
    else
      ans += (f - ((ans - s) % f)) + c
    end
  end
  puts ans
end
puts 0


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef   long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int n,m;
	cin>>n>>m;
	int a[n],b[n],c[m],d[m];
	rep(i,n)cin>>a[i]>>b[i];
	rep(i,m)cin>>c[i]>>d[i];
	rep(i,n){
		int ans=0,mn=1e9;
		rep(j,m){
			if(mn>abs(a[i]-c[j])+abs(b[i]-d[j])){
				mn=abs(a[i]-c[j])+abs(b[i]-d[j]);
				ans=j;
			}
		}
		cout<<ans+1<<"\n";
	}	

}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> V(N);
	REP(i, N)cin >> V[i];
	vector<ll> rV = V;
	reverse(rV.begin(), rV.end());

	ll goal = -INFL;
	for (ll i = 0; i <= min(K, N); i++) {
		REP(l, i + 1) {
			ll r = i - l;
			ll trush = K - i;
			vector<ll> res;
			REP(j, l)res.push_back(V[j]);
			REP(j, r)res.push_back(rV[j]);

			sort(res.begin(), res.end());
			ll acc = accumulate(res.begin(), res.end(), 0ll);
			REP(i, min(trush, (ll)res.size())) {
				goal = max(goal, acc);
				acc -= res[i];
			}
			goal = max(goal, acc);
		}
	}

	cout << goal << endl;
	return 0;
}


Measured memory_bytes: 256
A, B, C = [int(n) for n in input().split()]

if A == 5:
  if B == 5:
    answer = C == 7
  elif B == 7:
    answer = C == 5
  else:
    answer = False
elif A == 7:
  if B == 5:
    answer = C == 5
  else:
    answer = False
else:
  answer = False

if answer:
  print('YES')
else:
  print('NO')

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	VLL x(n + 10);
	REP(i, n)cin >> x[i];
	ll ans = 0;
	REP(i, n - 1) {
		ans += min(b, (x[i + 1] - x[i])*a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////


int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << max(a * c, max(a * d, max(b * c, b * d))) << endl;
}


Measured memory_bytes: 3632
import java.io.*;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		StringTokenizer st = new StringTokenizer(s, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		if(a < b) {
			System.out.println("a < b");
		}else if(a == b) {
			System.out.println("a == b");
		}else {
			System.out.println("a > b");
		}
	}

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i,N)cin>>a[i];

  sort(ALL(a));
  reverse(ALL(a));

  int d=0;
  REP(i,a.size()){
    if(i%2==0)d+=a[i];
    else d-=a[i];
  }
  cout << d << endl;

}



Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>
#include<queue>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)
#define in(i,j,k) ((i)>=(j)&&(i)<=(k))

	int dp[500][500];
	char s[501];
int main(){
	int h,w,ans;
	for(;;){
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)break;
		ans=0;
		rep(i,h){
			scanf("%s",s);
			rep(j,w)rep(k,2)dp[i][j]=s[j]=='.';
			rep(j,w){
				if(s[j]!='*'){
					if(i>0)dp[i][j]=dp[i-1][j]+1;
					int m=dp[i][j];
					reps(k,1,j+1){
						m=min(dp[i][j-k+1],m);
						ans=max(ans,m*k);
					}
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int N;
bool judge0(vector<int> A,vector<int> B){
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    bool isok=true;
    for(int i=0;i<N;i++) isok=isok&&(A[i]<=B[i]);
    return isok;
}

bool judge1(vector<int> A,vector<int> B){
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    bool isok=false;
    for(int i=N-1;i>0;i--){
        isok=isok || A[i]<=B[i-1];
    }
    return isok;
}


bool judge2(vector<int> A,vector<int> B){
    vector<pair<int,int>> pv(N);
    for(int i=0;i<N;i++) pv[i]={B[i],A[i]};
    sort(pv.begin(),pv.end());

    set<int> s;
    for(int i=0;i<N;i++) s.insert(A[i]);

    map<int,int> mpA;
    int id=0;
    for(auto v:s) mpA[v]=id++;

    vector<int> posA(N);
    vector<int> inv(N);
    for(int i=0;i<N;i++) posA[i]=mpA[pv[i].second];
    for(int i=0;i<N;i++) inv[posA[i]]=i;

    for(int i=0;i<N-2;i++){
        if(posA[i]==i){
            return true;
        }
        int v=posA[i];
        swap(posA[i],posA[inv[i]]);
        swap(inv[v],inv[i]);
    }
    return is_sorted(posA.begin(),posA.end());
}

void Yes(){
    cout<<"Yes"<<endl;
    exit(0);
}
void No(){
    cout<<"No"<<endl;
    exit(0);
}
int main(){
    cin>>N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i=0;i<N;i++) cin>>A[i];
    for(int i=0;i<N;i++) cin>>B[i];

    if(!judge0(A,B)) No();
    if(judge1(A,B)) Yes();
    
    if(judge2(A,B)) Yes();
    else No();
    return 0;
}


Measured memory_bytes: 12644
#include<cstdio>
#include<map>
#define maxn 200005
using namespace std;
int n,m,k,f[maxn],scc[maxn],x,y;
int find(int x){return x==f[x]?x:f[x]=find(f[x]);}
int f2(int x){return x==scc[x]?x:scc[x]=f2(scc[x]);}
map<pair<int,int>,int>cnt;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) f[i]=scc[i]=i;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		x=find(x),y=find(y);
		if(x!=y) f[y]=x;
	}
	for(int i=1;i<=k;i++)
	{
		scanf("%d%d",&x,&y);
		x=f2(x),y=f2(y);
		if(x!=y) scc[y]=x;
	}
	for(int i=1;i<=n;i++) f[i]=find(f[i]),scc[i]=f2(scc[i]);
	for(int i=1;i<=n;i++) cnt[make_pair(f[i],scc[i])]++;
	for(int i=1;i<=n;i++) printf("%d ",cnt[make_pair(f[i],scc[i])]);
}

Measured memory_bytes: 13568
n, k = map(int, input().split())
r = n - k

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

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

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


for i in range(1, k+1):
    if i == 1:
        num = r + 1
    else:
        r_ball = r - (i - 1)
        num_1 = cmb(r_ball+i, i, mod)
        num_2 = cmb(k-1, i-1, mod)
        num = (num_1 * num_2) % mod
    print(num)




Measured memory_bytes: 4584
#include <bits/stdc++.h>
//#include "/Users/tania/Downloads/stdc++.h"
using namespace std;
typedef long long int lli;

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

	if(s.size() <= n)
		cout<<s<<endl;
	else{
		for(int i=0; i<n; i++){
			cout<<s[i];
		}cout<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3600
import math
A = int(input())
def gcd(A):
    total = 0
    for i in range(1,A+1):
        for j in range(1,A+1):
            B = math.gcd(i,j)
            for k in range(1,A+1):
                total += math.gcd(B,k)
    return total
print(gcd(A))

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    string w;  cin >> w;

    vector<int> cnt(26, 0);
    rep(i, w.size()) {
        int num = (int)(w[i] - 'a');
        cnt[num]++;
    }

    bool flag = true;
    rep(i, 26) {
        if (cnt[i] % 2 != 0) {
            flag = false;
        }
    }

    if (flag) yes;
    else no;
}




Measured memory_bytes: 256
import numpy as np
import itertools
#from scipy import signal


n = int(input())
ajs = input().split()
ajs = [int(aj) for aj in ajs]
ajs = np.array(ajs)

#actions = itertools.product([-1, 0, 1], repeat=n)
#for action in actions:

ajs_delta = ajs[1:] - ajs[:-1]

for i in range(1, ajs_delta.shape[0]):
  if ajs_delta[i] == 0:
    ajs_delta[i] = ajs_delta[i-1]
    

  
kyokuchi = {'lower':[], 'upper':[]}
#maxId = signal.argrelmax(ajs)

first_value = 0
for aj_delta in ajs_delta:
  if aj_delta != 0:
    first_value = aj_delta
    break

if ajs_delta[0] > 0:
  kyokuchi['lower'].append(0)
elif ajs_delta[0] < 0:
  #kyokuchi['upper'].append(0)
  pass
elif ajs_delta[0]  == 0 and first_value > 0:
  kyokuchi['lower'].append(0)

for i in range(0, ajs_delta.shape[0]-1):
  if ajs_delta[i] * ajs_delta[i+1] < 0:
    if ajs_delta[i] > 0:
      kyokuchi['upper'].append(i+1)
    else:
      kyokuchi['lower'].append(i+1)

if ajs_delta[-1] > 0:
  kyokuchi['upper'].append(n-1)
else:
  #kyokuchi['lower'].append(n-1)
  pass


kyokuchi_s = sorted(kyokuchi['upper'] + kyokuchi['lower'])

current_money = 1000
pos = 0

for idx in kyokuchi_s:
  if pos >= 0:#買い
    stock = int(current_money / ajs[idx])
    current_money = current_money % ajs[idx]
    pos = -1
  else:
    current_money += stock * ajs[idx]
    stock = 0
    pos = 1
    
print(current_money)

Measured memory_bytes: 26988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,tot=0,temp;
  
    cin>>n>>m;

    while(cin>>temp)
        tot=temp+tot;
    
    if(n>=tot)
        cout<<n-tot<<endl;
    else
        cout<<-1<<endl;    

    return 0;
}


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

using namespace std;

int m; long long d[100000], u[100000];
vector<int> adj[100000];

void dfs1(int x, int p = -1) {
    d[x] = 1;
    for (int i = 0; i < adj[x].size(); i++) if (adj[x][i] != p) {
        dfs1(adj[x][i], x);
        d[x] *= d[adj[x][i]] + 1;
        d[x] %= m;
    }
}

void dfs2(int x, int p = -1) {
    int len = adj[x].size() + (x == 0);
    long long pfx[len], sfx[len];
    pfx[0] = sfx[len - 1] = 1;
    for (int i = 0, l = 0; i < adj[x].size(); i++) if (adj[x][i] != p) {
        pfx[l + 1] = pfx[l] * (d[adj[x][i]] + 1) % m;
        l++;
    }
    for (int i = adj[x].size() - 1, r = len - 1; i >= 0; i--) if (adj[x][i] != p) {
        sfx[r - 1] = sfx[r] * (d[adj[x][i]] + 1) % m;
        r--;
    }
    for (int i = 0, l = 0; i < adj[x].size(); i++) if (adj[x][i] != p) {
        u[adj[x][i]] = (u[x] * pfx[l] % m * sfx[l + 1] + 1) % m;
        dfs2(adj[x][i], x);
        l++;
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n >> m;
    for (int i = 0; i < n - 1; i++) {
        int x, y; cin >> x >> y;
        x--; y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs1(0); u[0] = 1;
    dfs2(0);
    for (int i = 0; i < n; i++) cout << d[i] * u[i] % m << endl;
    return 0;
}


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

ab = [[0]*2 for i in range(n)]

for i in range(n):
	ab[i][0], ab[i][1] = map(int, input().split())

ab.sort(key=lambda x: x[1])

ws = 0

for i in range(n):
	ws += ab[i][0]
	if ws > ab[i][1]:
		print('No')
		break
else:
	print('Yes')

Measured memory_bytes: 38040
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
d = 0
ans = 0


def temperature(x):
    return t - x * 0.006


for i in range(n):
    c = temperature(h[i])
    if i == 0:
        d = abs(a - c)
        ans = 1
    else:
        if abs(a - c) < d:
            d = abs(a - c)
            ans = i + 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

int N, C;
int tt[31][100005];
int main() {
  cin >> N >> C;

  rep(i, 31) {
    rep(j, 100005) {
      tt[i][j] = 0;
    }
  }

  int maxt = 0;
  rep(i, N) {
    int c, s, t;
    cin >> s >> t >> c;
    tt[c][s]++;
    tt[c][t]--;
    maxt = max(maxt, t);
  }

  int now = 0;
  int ans = 0;
  for(int i=1; i<=maxt; i++) {
    int tmp = 0;
    for(int j=1; j<=C; j++) {
      now += tt[j][i];
      if (tt[j][i] == -1) {
        tmp++;
      }
    }
    ans = max(now+tmp, ans);
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> lengths;
    for (int i = 0; i < n; i++) {
        long long l;
        cin >> l;
        lengths.push_back(l);
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (lengths[i] == lengths[j] || lengths[i] == lengths[k] || lengths[j] == lengths[k]) continue;
                if (lengths[i] < lengths[j] + lengths[k]) {
                    if (lengths[j] < lengths[i] + lengths[k]) {
                        if (lengths[k] < lengths[j] + lengths[i]) {
                            sum++;
                        }
                    }
                }
            }
        }
    }
    cout << sum;
}


Measured memory_bytes: 3664
#include <stdio.h>

int main(void) {
    unsigned long int i, count, sum, n;
    scanf("%lu", &n);

    for (i = 0, count = 0, sum = 0; i <= n; i++ ) {
        if (i % 3 != 0 && i % 5 != 0) {
            count++;
            sum += i;
        }
    }

    printf("%lu\n", sum);
    return 0;
}

Measured memory_bytes: 1736
def main():
    N, M = map(int, input().split())

    unit = M * 1900 + (N - M) * 100
    ans = unit * (1 << M)

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int K;
string S, tmp = "";


void solve(){
    if(K >= S.length() ) {
        cout << S << endl;
    } else {
        rep(i, K){
            tmp += S[i];
        }
        tmp += "...";
        cout << tmp << endl;
    }
}

int main(){
    cin >> K >> S;

    solve();
}


Measured memory_bytes: 3636
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n,m,dp[50000],a[1000],b[1000],x,d[1000]={};
    vector<int> c[1000];
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&a[i],&b[i]);
        for(int j=0;j<b[i];j++){
            scanf("%d",&x);
            c[i].push_back(x);
            d[i]+=(1<<(x-1));
        }
    }
    for(int i=0;i<(1<<n);i++){
        dp[i]=1000000000;
    }
    dp[0]=0;
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<m;j++){
            dp[i|d[j]]=min(dp[i|d[j]],dp[i]+a[j]);
        }
    }
    if(dp[(1<<n)-1]==1000000000){
        printf("-1\n");
    }
    else{
        printf("%d\n",dp[(1<<n)-1]);
    }
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& 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;
}
int modinv(int a, int m) {
	int 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;
}

signed main() {
	int n, ans = 0;
	cin >> n;
	int l[2005];
	rep(i, n) {
		cin >> l[i];
	}
	sort(l, l + n);
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			ans += lower_bound(l + j + 1, l + n, l[i] + l[j]) - (l + j + 1);
			//cout << lower_bound(l + j + 1, l + n, l[i] + l[j]) - (l + j + 1) << endl;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
from collections import Counter
N, M = map(int, input().split())
A = [0] + [int(i) for i in input().split()]

for i in range(N):
    A[i + 1] += A[i]
    A[i + 1] %= M

ans = 0
for i in Counter(A).values():
    if i > 1:
        ans += i * (i - 1) // 2

print(ans)

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> k(n);
    while (m--) {
        int a, b;
        cin >> a >> b;
        ++k[a - 1];
        ++k[b - 1];
    }
    for (int i = 1; i <= n; ++i) {
        if (k[i] % 2) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;




int main() {
	int H, W; cin >> H >> W;
	vector<string> s(H + 2);
	s[0] = s[H + 1] = string(W + 2, '#');
	for (int i = 1; i <= H; i++) {
		cin >> s[i];
		s[i] = '#' + s[i] + '#';
	}
	vector<vector<int>> r(H + 2, vector<int>(W + 2));
	vector<vector<int>> l(H + 2, vector<int>(W + 2));
	vector<vector<int>> u(H + 2, vector<int>(W + 2));
	vector<vector<int>> d(H + 2, vector<int>(W + 2));
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i][j] == '#') continue;
			l[i][j] = l[i][j - 1] + 1;
			u[i][j] = u[i - 1][j] + 1;
		}
	}
	for (int i = H; i >= 1; i--) {
		for (int j = W; j >= 1; j--) {
			if (s[i][j] == '#') continue;
			r[i][j] = r[i][j + 1] + 1;
			d[i][j] = d[i + 1][j] + 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i][j] == '#') continue;
			ans = max(ans, r[i][j] + l[i][j] + u[i][j] + d[i][j] - 3);
		}
	}
	cout << ans << endl;
	return 0;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    cout << x * min(n, k) + y * max(0, n - k) << endl;
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,k;
    cin>>n>>k;
    map<int,int> memo;
    rep(i,n){
        int a;
        cin>>a;
        memo[a]++;
    }
    int syurui=0;
    for(auto itr=memo.begin();itr!=memo.end();itr++){
        syurui++;
    }
    vector<int> amount(syurui);
    int i=0;
    for(auto itr=memo.begin();itr!=memo.end();itr++){
        amount.at(i)=(itr->second);
        i++;
    }
    sort(amount.begin(),amount.end());
    int Sum=0;
    rep(i,syurui-k) Sum+=amount.at(i);
    cout<<Sum<<endl; 
}


Measured memory_bytes: 10368
def judge(s):
  for i in range(len(s)//2):
    if s[i]!=s[-(i+1)]:
      return False
  else:
    return True

s=input()
if judge(s)==False:
  print('No')
else:
  if judge(s[:(len(s)-1)//2])==False:
    print('No')
  else:
    if judge(s[(len(s)+3)//2-1:])==False:
      print('No')
    else:
      print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;

int main(){
  string N; cin>>N;
  if(N[0] == '7' or N[1] == '7' or N[2] == '7') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

const int maxn=2e5+10,mod=998244353;
int n,mod3,dp[maxn][3][3][2],ans=1;
char s[maxn];

inline bool allthesame(){
	for(int i=2;i<=n;++i)
		if(s[i]!=s[1])
			return false;
	return true;
}

int main(){
	cin>>(s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)
		s[i]-='0';
	if(allthesame()){
		puts("1");
		return 0;
	}
	if(n<=3){
		if(n==2)
			puts("2");
		else if(s[1]==s[3])
			puts("7");
		else if(s[1]==s[2]||s[2]==s[3])
			puts("6");
		else
			puts("3");
		return 0;
	}
	for(int i=1;i<=n;++i)
		(mod3+=s[i])%=3;
	dp[1][0][0][0]=dp[1][1][1][0]=dp[1][2][2][0]=1;
	for(int i=1;i<n;++i)
		for(int j=0;j<3;++j)
			for(int k=0;k<3;++k)
				for(int l=0;l<2;++l)
					for(int x=0;x<3;++x)
						(dp[i+1][x][(x+k)%3][l||x==j]+=dp[i][j][k][l])%=mod;
	for(int i=0;i<3;++i)
		(ans+=dp[n][i][mod3][1])%=mod;
	for(int i=1;i<n;++i)
		if(s[i]==s[i+1]){
			ans=(ans+mod-1)%mod;
			break;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14464