akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
   string red,blue,u;
   int r,b;

    cin>>red>>blue;
    cin>>r>>b;
    cin>>u;
    if(red==u){

        r-=1;
    }
    else if(blue==u){
        b-=1;
    }
    cout<<r<<" "<<b<<endl;

        return 0;
}


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

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> h(N);
  for (ll i = 0; i < N; ++i)
  {
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  ll ans = INF;
  for (ll i = 0; i < N - K + 1; ++i)
  {
    ans = min(ans, h.at(i + K - 1) - h.at(i));
  }
  cout << ans << endl;
}


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

int d[200001];
 
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        d[i]=0;
    }
    for(int i=0;i<n-1;i++){
        int tmp;
        cin>>tmp;
        d[tmp-1]++;
    }
    for(int i=0;i<n;i++){
        cout<<d[i]<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 4412
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		int m=sc.nextInt();
		int ans[]=new int[n];
		int a[]=new int[2*m];
		for(int i=0;i<=2*m-2;i=i+2) {
			a[i]=sc.nextInt();
			a[i+1]=sc.nextInt();
			ans[a[i]-1]++;
			ans[a[i+1]-1]++;
		}
		for(int i=0;i<n;i++) {
		System.out.println(ans[i]);
	
		}
	}	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

const ll mod = 1000000007;

int main() {
    init();
    ll H, W, K;
    cin >> H >> W >> K;

    if(W==1){
        cout << 1 << endl;
        return 0;
    }
    vvc<ll> dp(H + 1, vl(W));
    dp[0][0] = 1;
    rep(i,H){
        rep(j,1<<W-1){
            bool isok = true;
            rep(k,W-1){
                if(j&(1<<k)&&j&(1<<k+1)){
                    isok = false;
                    break;
                }
            }
            if (!isok) continue; //立っているbitが連続していたら無視

            vc<bool> hasT(W, false); //左か右が横線で繋がっていたらtrue
            hasT[0] = (j & 1);
            rep(k,W){
                if(j&1<<(k-1)||j&1<<(k))
                    hasT[k] = true;
            }

            rep(k,W){
                if(j&(1<<k)){
                    dp[i + 1][k + 1] += dp[i][k] % mod;
                    dp[i + 1][k] += dp[i][k + 1] % mod;
                }else if(hasT[k]==false){
                    dp[i + 1][k] += dp[i][k] % mod;
                }
            }
            rep(k, W) dp[i + 1][k] %= mod;
        }
    }
    cout << dp[H][K-1] << endl;
}   

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

int main() {
  int X,Y;
  cin >> X >> Y;
  int a=2*X-Y/2;
  int b=Y/2-X;
  if(Y%2==0 && a>=0 && b>=0){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}




Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5;
int n, h[maxN], memo[maxN];

int solve(int i)
{
  if (memo[i] != -1) return memo[i];
  if (i == n - 1) return memo[i] = 0;
  if (i == n - 2) return memo[i] = abs(h[i] - h[i + 1]);
  return memo[i] = min(solve(i + 1) + abs(h[i] - h[i + 1]), solve(i + 2) + abs(h[i] - h[i + 2])); 
}
int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &h[i]);
  memset(memo, -1, sizeof(memo));
  printf("%d\n", solve(0));
  return 0;
}
/* f(i): min(f(i + 1) + abs(h[i] - h[i + 1]), f(i + 2) + abs(h[i] - h[i + 2])); */

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int n,s1=0,s2=0,ans=99999;
std::vector<int> w;
int main(){
  cin >> n;
  w.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> w[i];
    s2 += w[i];
  }
  for (size_t i = 0; i < n-1; i++) {
    s1 += w[i];
    s2 -= w[i];
    if(ans > abs(s1-s2)){
      ans = abs(s1-s2);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 

using namespace std;

//#Rohitpratap311
//#Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;

int main()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    ll dp[n+1][W+1];
    for(ll i=0;i<n+1;i++)
    {
        for(ll j=0;j<W+1;j++)
        {
            if(i==0||j==0) { dp[i][j]=0; }
            else
            {
                dp[i][j]=dp[i-1][j];
                if(j-w[i-1]>=0)
                {
                    dp[i][j]=max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
                }
            }
        }
    }
    cout<<dp[n][W];
	return 0;
}

Measured memory_bytes: 82404
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;


int v[1010];
int w[1010];
int dp[1010][10010];
int n,W;
int main(){
	cin >>n>>W;
	for (int i = 0; i < n; i++){
		cin>>v[i]>>w[i];
	}
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j <= W; j++){
			if (j-w[i] >= 0){
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
			else{
				dp[i + 1][j] = dp[i][j];
			}

		}

	}

	cout << dp[n][W]<<endl;
	return 0;
}

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

using namespace std;

int dp[1000000][3];

int main(){
    int N;
    cin >> N;
    for(int i = 1; i<=N; i++){
        for(int j = 0; j<3; j++){
            int k;
            cin >> k;
            dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + k;
        }
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}


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

int main() {
  int N;
  string ans = "Three";
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if (S == "Y") {
      ans = "Four";
      break;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 112000000012345678LL

int main(){
  int n;
  cin>>n;
  vector<int> vec(n);
  vector<char> ch(n);
  cin>>vec[0]; ch[0]='+';
  rep(i,1,n) scanf(" %c %d", &ch[i], &vec[i]);

  long ans = 0;
  rep(i,n){
    if(ch[i]=='+') ans += vec[i];
    else ans -= vec[i];
  }

  long acc = accumulate(all(vec), 0LL);

  rep(i,n) if(ch[i]=='-'){
    acc -= 2*vec[i];
    long cur = acc;
    for(int j=i+1; j<n && ch[j]=='+'; j++) cur -= 2*vec[j];
    ans = max(ans, cur);//dbg(cur);
  }

  cout << ans << endl;

  return 0;
}


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

int main() {

  int num;
  cin>>num;

  if (65 <= num && num <= 90) {
    cout<<"1"<<endl;
  } else if (97 <= num && num <= 122) {
    cout<<"2"<<endl;
  } else {
    cout<<"0"<<endl;
  }

  return 0;
}



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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> v;
    if(N == 0){
        cout << 0 << endl;
    }else{
        while(1){
        if(N == 0){
            break;
        }
        v.push_back(abs(N) % 2);
        if(N > 0){
            N /= 2;
            N *= -1;
        }else if(N < 0){
            N *= -1;
            N = (N + 1) / 2;
        }
    }
    reverse(v.begin(),v.end());
    for(int i = 0;i < v.size() ; i++){
        cout << v.at(i);
    }
    cout << endl;
    }
}

Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
int a[maxn][maxn],b[maxn][maxn],c[maxn][maxn];
int dp[maxn][maxn][15000];
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>b[i][j];
            c[i][j]=b[i][j]-a[i][j];
        }
    }
    dp[1][1][7000+c[1][1]]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            for(int q=0;q<=14000;q++){
                if(dp[i][j][q]==1){
                    dp[i+1][j][q+c[i+1][j]]=1;
                    dp[i][j+1][q+c[i][j+1]]=1;
                    dp[i+1][j][q-c[i+1][j]]=1;
                    dp[i][j+1][q-c[i][j+1]]=1;
                }
            }
        }
    }
    int ans=inf;
    for(int i=1;i<=14000;i++){
        if(dp[n][m][i]==1){
            ans=min(ans,abs(7000-i));
        }
    }
    cout<<ans;
	exit(0);
}


Measured memory_bytes: 547200
N = int(input())


def DFS(N, S):
    if len(S) == N:
        print(S)
    else:
        next_chrs = []
        if S:
            next_max_chr = ord(max(S)) + 1
        else:
            next_max_chr = ord("a")
        for i in range(0, next_max_chr - ord("a") + 1):
            DFS(N, "".join([S, chr(ord("a") + i)]))


DFS(N, "")

Measured memory_bytes: 4340
X,N = input().split()
X,N = int(X),int(N)

P = input().split()
P = [int(c) for c in P]

i = X
j = X

if len(P) == 0:
    print(X)    
elif X  not in P:
    print(X)
else:
    while i < 101:
        i += 1
        if i not in P:
            break
    while j > 0:
        j -= 1
        if j not in P:
            break
    
    if i - X >= X - j:
        print(j)
    else:
        print(i)

Measured memory_bytes: 9140
n = int(input())
a = list(map(int, input().split()))
if n == 1:
	if a[0] == 1:
		print (0)
		exit()
	else:
		print (-1)
		exit()
if len(set(a)) == 1 and a[0] != 1:
	print (-1)
	exit()
 
x = 1
cnt = 0
for i in a:
	if i == x:
		x += 1
	else:
		cnt += 1
if cnt == n:
	print (-1)
else:
	print(cnt)

Measured memory_bytes: 26148
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

const int MAX_V = 51;
LL d[MAX_V][MAX_V];//d[i][j]はe={u,v}のコスト
int n;
int a[1010], b[1010];

void warshall_floyd() {
	for (int k = 0; k < 51; k++) {
		for (int i = 0; i < 51; i++) {
			for (int j = 0; j < 51; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main() {
	cin >> n;
	REP(i, n)cin >> a[i];
	REP(i, n)cin >> b[i];
	LL ans = 0;
	vector<int> edge;
	for (int p = 51; p >= 1; p--) {
		REP(i, 51)REP(j, 51)d[i][j] = LINF/100;
		REP(i, 51)d[i][i] = 0LL;
		for (int i : edge) {
			REP(u, 51)d[u][u%i] = 0LL;
		}
		for (int i = 1; i < p; i++) {
			REP(u, 51)d[u][u%i] = min(d[u][u%i], 1LL << i);
		}
		warshall_floyd();
		bool check = true, clear = true;
		REP(i, n) {
			check &= (d[a[i]][b[i]] != LINF/100);
			clear &= (d[a[i]][b[i]] == 0LL);
		}
		if (clear)break;
		if (!check) {
			if (p == 51) {
				cout << -1 << endl;
				return 0;
			}
			else {
				edge.emplace_back(p);
			}
		}
	}
	for (int i : edge)ans |= (1LL << i);
	cout << ans << endl;
	//system("pause");
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
using namespace std;

ll q=1;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a;
    cin >> n;
    vector<ll> x;
    for(ll i=0;i<n;i++){
        cin >> a;
        x.push_back(a);
    }
    ll ans=0;
    sort(x.begin(),x.end());
    for(ll i=0;i<x.size();i++){
        if(x[i]==x[i+1]){
            q++;
        }
        else if(x[i]!=x[i+1]){
            if(q%2==1){
                ans++;
            }
            q=1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
 
 
int main(void){
  int dsum = 0;
  int N;
  scanf ("%d",&N);
 
  int tmp = N;
 
while (tmp > 0){
  dsum += tmp % 10;
  tmp = tmp / 10;
}
 
  if ((N % dsum) != 0){
    printf("No\n");
  }
  else{
    printf("Yes\n");
    }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
       string s ; int i;
       cin >> s;
       for(i=0 ; i< s.length() ; i++ ){
           if (s[i]==','){
               s[i] = ' ' ;
           }
           cout<< s[i] ;
       }
    return 0;
}

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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
	Boost();

	int test;
	cin >> test;

	int a, b, z;
	a = b = z = 0;
	while(test--) {
		int t, x, y;
		cin >> t >> x >> y;

		int dist = abs(x - a) + abs(y - b);
		int difT = t - z;

		if(dist > difT) {
			cout << "No";
			exit(0);
		}
		 int rem = difT - dist;

		 if(rem % 2 == 1) {
			 cout << "No";
			 exit(0);
		 }

		a = x;
		b = y;
		z = t;
	}

	cout << "Yes";
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,w=0,q=0,d;
  int b[10000000]={};
  int c[10000000]={};
  cin>>a;
  int pa=0,pb=0,ma=0,mb=0;
  for(int i=0;i<a;i++){
    cin>>d;
    if(i%2==0){
      b[d]++;
      if(b[d]>w) pa=d;
      w=max(w,b[d]);
    }
    else{
      c[d]++;
      if(c[d]>q) pb=d;
      q=max(q,c[d]);     
    }
  }
  if(pa==pb){
    for(int i=0;i<=1000000;i++){
        if(pa!=i){
          ma=max(ma,b[i]);
        }
        if(pb!=i){
          mb=max(mb,c[i]);
        }
      //cout<<i<<" "<<ma<<" "<<mb<<"\n";
    }
    if(ma<mb) q=mb;
    else w=ma;
    
  }
  cout<<a-w-q<<"\n";
}


Measured memory_bytes: 78336
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] A = in.nextIntArray(N);
            long[] sum = new long[N + 1];
            for (int i = 0; i < N; i++) {
                sum[i + 1] = sum[i] + A[i];
            }
            Map<Long, Long> map = new HashMap<>();
            long ans = 0;
            for (int i = 0; i < N + 1; i++) {
                long n = sum[i] % M;
                long v = map.getOrDefault(n, 0L);
                ans += v;
                map.put(n, v + 1);
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 42976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,k;
ll a[200005];
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>=k){
            if(a[i]>a[i-k]){
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }
    }
    
}


Measured memory_bytes: 5200
#include<iostream>
#include<algorithm>
using namespace std;
bool dp[1000001];
bool isprime(int& x){
  for(int i = 2 ; i * i <= x ; i++ ) if( x % i == 0) return true;
  return x == 1;
}
int solve(int i){
  while(true){ if(dp[i] && !isprime(i)) return i; i--; }
}
int main(){
  int n,x,data[30],ans; dp[0] = true;
  while(cin >> n >> x , n){
    for(int i = 1 ; i <= x ; i++ ) dp[i] = false;
    for(int i = 0 ; i < n ; i++ ) cin >> data[i];
    for(int i = 0 ; i <= x ; i++ ){
      if(dp[i]) for(int j = 0 ; j < n ; j++ )
        if(i + data[j] <= x) dp[i+data[j]] = true;
    }
    if(ans = solve(x)) cout << ans << endl;
    else cout << "NA" << endl;
  }
}

Measured memory_bytes: 2136
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll N;
int X, M;
bool used[100100];

int main() {
    cin >> N >> X >> M;
    ll ans = 0;
    ll x = X;
    vector<int> S;
    while (!used[x]) {
        used[x] = true;
        S.push_back(x);
        x = x * x % M;
    }
    ll sum = 0;
    bool flag = false;
    vector<int> V;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == x) flag = true;
        if (flag) { 
            sum += S[i];
            V.push_back(S[i]);
        } 
        else ans += S[i];
    }
    ll t = N - S.size() + V.size();
    ans += sum * (t / V.size());
    for (int i = 0; i < t % V.size(); i++) ans += V[i];
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int num[27];
int main(){
  string s;
  char a,b;
  cin >> s;
  for(int i=0;i<4;i++){
    num[s[i] - 'A']++;
  }
  int c = 0;
  for(int i=0;i<27;i++){
    if(num[i] == 2)c++;
  }
  if(c == 2){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
S = input()

if len(S) % 2 != 0:
    print("No")
else:
    i,flag = 0,True
    while i+1 <= len(S):
        if S[i] == "h" and S[i+1] == "i":
            i += 2
        else:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


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

int main(){
    int x,y;
    cin  >> x >>y;
    int num=x+y;
    for(int i=1;i<=x;i++){
        for(int j=1;j<=y;j++){
            if(x*j==y*i){
                num--;
                //cout << i << " " << j<< endl;
            }
        }
    }
    cout << num+1 << endl;
    return 0;
}

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

using namespace std;

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

void solve() {
  int n;
  cin >> n;
  while(n%111) n++;
  cout << n << endl;
}

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


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		HashMap<Character, Integer> map = new HashMap<>();
		for(char c : r.str().toCharArray())
		{
			if(Character.isLowerCase(c)) {
				map.put(c, map.getOrDefault(c, 0)+1);
			}
		}
		for(Map.Entry<Character,Integer> ent : map.entrySet())
		{
			if((ent.getValue()%2)==1)
			{
				print("No");
				return;
			}
		}
		print("Yes");
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}

Measured memory_bytes: 22740
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    boolean ans = false;

    for(int i = 1 ; i <= 9 ; ++i){
      for(int j = 1 ; j <= 9 ; ++j){
        if(i*j==n){
          ans = true;
          break;
        }
      }
    }
    if(ans) System.out.println("Yes");
    else System.out.println("No");
    
  }
}

Measured memory_bytes: 35576
import java.math.BigInteger;
import java.util.*;

public class Main {
    static int n;
    static int[] a;
    static int mod = (int) 1e9 + 7;
    static CombMod comb = new CombMod((int) 1e5 + 1, mod);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt() +1;
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int[] b = new int[n+1];
        for (int i = 0; i < n; i++) {
            b[a[i]]++;
        }
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (b[i] == 2) {
                c = i;
                break;
            }
        }
        int x = -1;
        int y = -1;
        for (int i = 0; i < n; i++) {
            if (a[i] == c) {
                if (x == -1) {
                    x = i;
                } else {
                    y = i;
                    break;
                }
            }
        }

        int l = Math.abs(x - y);
        System.out.println(n-1);
        for (int i = 2; i <= n; i++) {
            long sum = comb.comb(n, i);
            long tmp = (n - l >= i) ? comb.comb(n - l -1, i-1) : 0;
            System.out.println((mod + sum - tmp) % mod);
        }
    }

}

class CombMod {
    long dp[];
    long dpi[];
    long mod;
    BigInteger bigMod;
    BigInteger bigMod2;

    CombMod(int n, int mod) {
        this.mod = mod;
        bigMod = BigInteger.valueOf(mod);
        bigMod2 = BigInteger.valueOf(mod - 2);
        dp = new long[n + 1];
        dpi = new long[n + 1];
        dp[0] = 1;
        dp[1] = 1;
        dpi[1] = 1;
    }

    long fact(int m) {
        if (dp[m] != 0) {
            return dp[m];
        }
        dp[m] = m * fact(m - 1) % mod;
        return dp[m];
    }

    long facti(int m) {
        if (dpi[m] != 0) {
            return dpi[m];
        }
        dpi[m] = BigInteger.valueOf(m).modPow(bigMod2, bigMod).intValue() * facti(m-1) % mod;
        return dpi[m];
    }

    long comb(int m, int n) {
        return (m == n) ? 1:fact(m) * facti(m-n) % mod * facti(n) % mod;
    }
}


Measured memory_bytes: 118660
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin>>N && N){
    vector<int> a(N + 1);
    vector<int> ans;
    REP(i, N + 1) cin>>a[i];
    REP(i, N + 1){
      vector<int> b;
      REP(j, N + 1) if(i != j) b.push_back(a[j]);
      set<int> s;
      REP(j, b.size() - 1) s.insert(b[j + 1] - b[j]);
      if(s.size() == 1){
        ans.push_back(a[i]);
      }
    }
    //assert(ans.size() == 1);
    cout<<ans.back()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ret = sum(b)

for i in range(n-1):
  if a[i]+1 == a[i+1]:
    ret+=c[a[i]-1]


print(ret)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split(' ')))

count = 0
for i in range(N-1):
    minj = i
    increment = 0
    for j in range(i+1, N):
        if A[minj] > A[j]:
            minj = j
            increment = 1
    count += increment
    A[i], A[minj] = A[minj], A[i]
print(*A)
print(count)


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

A, B, H, M = map(int, input().split())

at_d = (3-(H+M/60))%12 * 30
bt_d = (15-M)%60 * 6

# print(at_d, bt_d)

at_r = radians(at_d)
bt_r = radians(bt_d)

ax, ay = (cos(at_r)*A, sin(at_r)*A)
bx, by = (cos(bt_r)*B, sin(bt_r)*B)

r = ((ax-bx)**2 + (ay-by)**2)**(1/2)
print(r)

Measured memory_bytes: 9468
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=l;i<r;i++)
#define LINF (ll)1e18
#define INF (int)1e9
struct aaa{aaa(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(10);};}aaaaaaa;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){
    cin>>head;
    in(move(tail)...);
}
template <class T>
inline void out(T t) {
    cout<<t<<'\n';
}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){
    cout<<head<<' ';
    out(move(tail)...);
}

int main(){
#define int ll
    int n;
    in(n);
    vector<int> a(n);
    rep(i,0,n){
        in(a[i]);
        a[i]-=i;
    }
    sort(a.begin(), a.end());
    int ans=0;
    rep(i,0,n){
        ans+=abs(a[i]-a[n/2]);
    }
    out(ans);
}



















Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		while(s.hasNext()){
			int d=s.nextInt();
			int S=0;
			for(int i=0;i<600/d;i++){
				S=S+d*d*i*d*i;
			}
			System.out.println(S);
		}
	}
}
//by Tuvshee 12.05.2012
//Integral

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

int main(){
  int dentyu[5], k;

  for(int i = 0; i < 5; i++){
    cin >> dentyu[i];
  }
  cin >> k;

  for(int i = 0; i < 5; i++){
    for(int j = i+1; j < 5; j++){
      if(dentyu[j] - dentyu[i] > k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;
}

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

int main() {
	int N, p;
	cin >> N;
	int total = 0;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> p;
		vec.at(i) = p;
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	vec.at(0) /= 2;
	for (int j = 0; j < N; j++) {
		total += vec.at(j);
	}
	cout << total << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define MAX 200001

bool visited[MAX];
vector<int> es[MAX];

int main(void){
    int n, m;
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        int k, l;
        cin >> k;
        for(int j=0; j<k; j++){
            cin >> l;
            es[i].push_back(n+l);
            es[n+l].push_back(i);
            //cerr << "set: " << i << " -- " << n+l << endl;
        }
    }
    int ct = 0;
    queue<int> q;
    q.push(1);
    visited[1] = true;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        //cerr << "visit: " << x << (x<=n ? " / person " : " / language ") << (x<=n ? x : x-n) << endl;
        if(x<=n) ct++;
        for(int y : es[x]){
            if(!visited[y]){
                //cerr << "edge: " << x << " -- " << y << endl;
                visited[y] = true;
                q.push(y);
            }
        }
    }
    cout << (ct==n ? "YES" : "NO") << endl; 
}


Measured memory_bytes: 8952
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

ll A[100000];
ll B[100000];
ll diff[100000];
int main(){
  int N;
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  ll sumA = 0;
  ll sumB = 0;
  rep(i, N) sumA += A[i];
  rep(i, N) sumB += B[i];
  if(sumA < sumB){
    puts("-1");
    return 0;
  }
  rep(i, N) diff[i] = A[i] - B[i];
  sort(diff, diff + N);
  reverse(diff, diff + N);
  /*
  rep(i, N){
    printf("diff = %lld\n", diff[i]);
  }
  */
  ll sum = 0;
  ll ans = 0;
  rep(i, N){
    if(A[i] < B[i]){
      sum += B[i] - A[i];
      ans++;
    }
  }
  rep(i, N){
    if(sum <= 0){
      printf("%lld\n", ans);
      return 0;
    }
    //printf("sum = %lld\n", sum);
    sum -= diff[i];
    ans++;
  }
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
int T,N,K,X[100000+10],A[100000+10];
int total();

int main() {
  cin >> T;
  for (int t=0;t<T;t++) {
    cin >> N >> K;
    for (int i=0;i<N;i++) cin >> X[i];
    for (int i=0;i+1<N;i++) A[i] = X[i+1]-X[i];
    sort(A,A+N-1);
    cout << max(0,total()) << endl;
  }
}

int total() {
  int sum = 0;
  if (0<N-1-(K-1)) {
    for (int i=0;i<N-1-(K-1);i++) {
      sum += A[i];
    }
  }
  return sum;
}

Measured memory_bytes: 1956
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  long long ans=a[0];
  int t=1;
  for(int i=1;i<n-1;i++){
    if(t==n-1)break;
    for(int j=0;j<2;j++){
      ans+=a[i];
      t++;
      if(t==n-1)break;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4028
//#include <unordered_set>
//#include <unordered_map> 
#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
    
using namespace std;
     
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define al 0x3F3F3F3F
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define resize(v) v.resize(unique(all(v)) - v.begin());
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair < ll, int > pli;
typedef pair <double, double> pdd;
typedef pair <int, double> pid;
typedef pair <double, int> pdi;
typedef pair <ll, double> pld;
typedef pair <double, ll> pdl;
    
const int mod = (int)1e9 + 7;
const int MAX_N = (int)2e5 + 123;
const int N = 1e6 + 3;
const int INF = al;           
const ll INFL = 3e18 + 1;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, ans, a[201];

inline int gcd(int a, int b) {
	if (!b) return a; 
    return gcd(b, a % b);                  
}                                    
                                                                                                      
inline void boost() {
    ios_base :: sync_with_stdio(NULL);
    cin.tie(NULL), cout.tie(NULL);
}
    
inline void Solve() {    
    boost();
    cin >> n;
    for (int i = 1; i <= n + n; i ++) cin >> a[i];
    sort(a + 1, a + n + n + 1);
    reverse(a + 1, a + n + n + 1);
    for (int i = 1; i < n + n; i += 2) {
    	ans += min(a[i], a[i + 1]);
    }
    cout << ans;
    
}

main () {
//	freopen("differ.in", "r", stdin);
//	freopen("differ.out", "w", stdout);                   	
    int tt = 1;
    while (tt--) {
        Solve();
		}
}         

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int tukukoma[n];
	for(int i=0;i<n;i++){
		cin>>tukukoma[i];
	}
	for (int i=n-1;i>=0;i--){
		if(i==n-1){
			cout<<tukukoma[i];
			}else{
		cout<<" "<<tukukoma[i];
	}
}
		cout<<endl;
	}


Measured memory_bytes: 3084
X = gets.to_i
X5 = Hash.new
ans = nil

(0 .. X).find do |a|
  a5 = a ** 5
  X5[a5] = a
  
  b5 = a5 - X
  
  if X5[b5]
    b = X5[b5]
  elsif X5[-b5]
    b = -X5[-b5]
  end
  if b
    ans = [a, b]
  end
end
puts ans.join(' ')


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    Vec v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(ALL(v));
    cout<<(v[0]+10*v[2]+v[1])<<endl;
    return  0;
}


Measured memory_bytes: 256
import numpy as np
from itertools import product

if __name__ == '__main__':
    T = input().split()
    N = int(T[0])
    M = int(T[1])
    X = int(T[2])
    price = np.zeros(N)
    qual = np.zeros((N, M))
    for n in range(N):
        t = input().split()
        price[n] = int(t[0])
        qual[n, :] = np.array([int(m) for m in t[1:]])

    cost_min = 1e18
    for idx in product([0, 1], repeat=N):
        cost = 0
        t = X * np.ones(M)
        for j in range(N):
            if idx[j] == 1:
                t -= qual[j, :]
                cost += price[j]
        if max(t) <= 0:
            if cost < cost_min:
                cost_min = cost
    if cost_min == 1e18:
        print(-1)
    else:
        print(int(cost_min))

Measured memory_bytes: 27172
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N;
    string S;
    cin >> N >> S;

    vector<ll> w(N), b(N);
    b[0] = (S[0]=='#') ? 1 : 0;
    w[N-1] = (S[N-1]=='.') ? 1 : 0;
    for(int i=1; i<N; i++){
        b[i] = b[i-1];
        if(S[i]=='#') b[i]++; 
    }
    for(int i=N-2; i>=0; i--){
        w[i] = w[i+1];
        if(S[i]=='.') w[i]++;
    }

    ll ans = min(w[0], b[N-1]);
    for(int i=0; i<N-1; i++) ans = min(ans, b[i]+w[i+1]);

    cout << ans << endl;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
ll MOD = 1e9+7;
ll po(ll a,ll b){
  if(b==1) return a%MOD;
  ll tb = po(a%MOD,b/2);
  ll ret = tb*tb%MOD;
  if(b%2==1) ret = ret*a%MOD;
  return ret;
}
int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  fillModInv(max(a,b),MOD);

  ll da = 1;
  REP(i,a){
    da *= n-i;
    da %= MOD;
    da *= modinv[i+1];
    da %= MOD;
  }
  ll db = 1;
  REP(i,b){
    db *= n-i;
    db %= MOD;
    db *= modinv[i+1];
    db %= MOD;
  }
  //ll ans = 1;
  //REP(i,n){
  //  ans *= 2;
  //  ans %= MOD;
  //}
  ll ans = po(2,n);
  ans = ans - 1 - da - db + 3*MOD;
  ans %= MOD;
  //DEBUG(ans);
  //DEBUG(da);
  //DEBUG(db);
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF  = 0x3f3f3f3f3f3f3f3f;
const int MOD  = 1000000007;
const int MAXN = 200005;
const int M = 1000005;

int vis[M], a[MAXN], dp[M];

void run() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        if(vis[a[i]]==0) {
            for(int j = 2*a[i]; j<M;j+=a[i]) {
                dp[j] = 1;
            }
        }
        vis[a[i]]++;
    }
    int cnt = 0;
    for(int i=0;i<n;i++) {
        if(vis[a[i]]>1) continue;
        if(dp[a[i]]==0) cnt++;
    }
    cout << cnt << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}

Measured memory_bytes: 12256
from itertools import product
def tako(ds):
    products = [each[0]*each[1] for each in list(product(ds, ds))]
    self_sum = sum([item**2 for item in ds])
    return (sum(products) - self_sum)//2

n = int(input())
ds = list(map(int, input().split()))
output = tako(ds)
print(output)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

int main()
  {
  ios_base::sync_with_stdio(0); 
  LD a;
  LD b;
  cin >> a >> b;
  LL x = a * b;
  printf("%lld\n", x);

  }



Measured memory_bytes: 3816