akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	int count = 0;
	for (int i = 0; i < x; i++) {
		string str;
		cin >> str;
		for (int j = 0; j < y; j++) {
			count += str[j] == '#';
		}
	}
	cout << (count==x+y-1 ? "Possible" : "Impossible");
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,minn,dem = 1,k;
int main()
{
    cin >> n;
    for(int i = 1;i <= n;i ++)
    {
        cin >> k;
        if(i == 1) minn = k;
        else
        {
            if(minn >= k)
            {
                minn = k;
                dem ++;
            }
        }
    }
    cout << dem;
    return 0;
}

/*#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,maxx = 1e8,dem = 1;
ll a[200001];
int main()
{
    dem = 0;
    cin >> n;
    for(int i = 1;i <= n;i ++) cin >> a[i];
    for(int i = 1;i <= n;i ++)
    {
        maxx = a[i];
        for(int j = 1;j <= i;j ++)
        {
            if(a[i] > a[j]) maxx = a[j];
        }
        if(maxx == a[i]) dem ++;
    }
    cout << dem;
    return 0;
}
*/


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

int main()
{
    int n;cin>>n;
    vector<double> v(n);
    for(int i = 0; i<n; i++) cin>>v[i];
    sort(v.begin(), v.end());
    for(int i = 1; i < n; i++){
        v[i] = (v[i] + v[i-1])/2.0;
    }

    cout <<fixed <<  setprecision(10)<< v[n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
"use strict";

function Main(input) {
  let lines = input.split('\n');
  // 青カードの切り出し
  let bluesNum = lines.shift();
  let blues = lines.splice(0,bluesNum);
  // 赤カードの切り出し
  let redsNum = lines.shift();
  let reds = lines.splice(0,redsNum);
  
  //それぞれをオブジェクトにして数を調べる
  let bluesObj = {};
  let redsObj = {};
  // 赤と青それぞれをオブジェクト化
  for(let i = 0; i < blues.length; i++){
  	bluesObj[blues[i]] == undefined ? bluesObj[blues[i]] = 1 : bluesObj[blues[i]]++;
  }
  
  for(let j = 0; j < reds.length; j++){
  	redsObj[reds[j]] == undefined ? redsObj[reds[j]] = -1 : redsObj[reds[j]]--;
  }
  // blueObjの値にredObjの値を重ねる
  for(let s in redsObj){
  	bluesObj[s] != undefined ? bluesObj[s] += redsObj[s]: "";
  }
  
  // Object.valuesはサポートしてないので、各値を抽出する式
  let bluesNums = Object.keys(bluesObj).map((key) => {
    return bluesObj[key];
  });
  
  // 最大値を出す、それらの値がマイナスだったら0になるように三項演算子
  let ans = Math.max(...bluesNums) < 0 ? 0 : Math.max(...bluesNums);
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap());
    let x = it.next().unwrap();
    let y = it.next().unwrap();
    let g1 = vec![1, 3, 5, 7, 8, 10, 12];
    let g2 = vec![4, 6, 9, 11];
    let g3 = vec![2];
    if g1.contains(&x) && g1.contains(&y) {
        println!("Yes");
    } else if g2.contains(&x) && g2.contains(&y) {
        println!("Yes");
    } else if g3.contains(&x) && g3.contains(&y) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
#define ll long long
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
	F(i,1,6){
		int x; cin>>x;
		if(i!=x){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  ll a, p; cin >> a >> p;
  cout << (a * 3 + p) / 2 << endl;
}


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

int main(){
  	int c[9];
  	for (int i = 0; i < 9; i++){
      	cin >> c[i];
    }  
  	int b1, b2, b3;
  	bool flag = false;
  	for (int a1 = -100; a1 < 200; a1++){
      	for (int a2 = -100; a2 < 200; a2++){
      		for (int a3 = -100; a3 < 200; a3++){
              	bool flag_ = true;
              	b1 = c[0] - a1;
              	b2 = c[1] - a1;
              	b3 = c[2] - a1;
              	if (a2 + b1 != c[3]) flag_ = false;
              	if (a2 + b2 != c[4]) flag_ = false;
              	if (a2 + b3 != c[5]) flag_ = false;
              	if (a3 + b1 != c[6]) flag_ = false;
              	if (a3 + b2 != c[7]) flag_ = false;
              	if (a3 + b3 != c[8]) flag_ = false;
              	if (flag_ == true) flag = true;
            }
    	}
    }
  	if (flag == true) cout << "Yes" << endl;
  	if (flag == false) cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h> 

int main (){
	int i, j, v, n,k;
	int A[1000000];

	scanf("%d", &n);
	for(i = 0; i < n; i++){	
		scanf("%d", &A[i]);
	} 
	for (k=0; k<n-1 ; k++)printf("%d ", A[k]);
	printf("%d\n",A[n-1]);
	for (i = 1 ; i < n; i++ ){
		v = A[i];
		j = i-1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
			A[j+1]=v;  
		}  
			for (k=0; k<n-1 ; k++)printf("%d ", A[k]);
			printf("%d\n",A[n-1]);
	}
	return 0; 
}

Measured memory_bytes: 1812
import math

N,D=map(int,input().split())
X=[[0]*D]*N
for i in range(0,N):
    X[i]=list(map(int,input().split()))

count=0

for i in range(0,N-1):
    for j in range(i+1,N):
        s=0
        for k in range(0,D):
            s=s+(X[i][k]-X[j][k])**2
        if int(math.sqrt(s))==math.sqrt(s):
            count=count+1

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

int H, W;
std::map<char, int> cnt;

int main()
{
  std::cin >> H >> W;
  rep( i, H )
  {
    std::string s;
    std::cin >> s;

    rep( j, s.size() )
      ++cnt[s[j]];
  }
  
  int g1 = (H%2)*(W%2), g2 = (H/2)*(W%2)+(H%2)*(W/2), g4 = (W/2)*(H/2);

  for( auto it = cnt.begin(); it != cnt.end(); ++it )
  {
    int &c = it->second;

    if( g4 > 0 )
      g4 -= c/4, c %= 4;
    if( g2 > 0 )
      g2 -= c/2, c %= 2;
    if( g1 > 0 )
      g1 -= c, c = 0;

    if( c != 0 )
    {
      puts( "No" );

      return 0;
    }
  }

  puts( "Yes" );

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int A[101000];
	int N;
	scanf("%d",&N);
	for (int i = 0; i < N; ++i)
	{
		scanf("%d",&A[i]);
	}
	sort(A,A+N);
	int count=1;
	for (int i = 1; i < N; ++i)
	{
		if(A[i]!=A[i-1]) count++;
	}
	printf("%d\n",N-(N-count+1)/2*2);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stdlib.h>
using namespace std;

int jump(vector<int>* p_heights){

    vector<int> table(p_heights->size(), 0);

    table[0] = 0;
    table[1] = abs((*p_heights)[1] - (*p_heights)[0]);
    for(int i = 2; i < (int)p_heights->size(); i++){
        int diff_1 = abs((*p_heights)[i] - (*p_heights)[i-1]);
        int diff_2 = abs((*p_heights)[i] - (*p_heights)[i-2]);
        table[i] = min(table[i-1]+diff_1, table[i-2]+diff_2);
    }

    return table.back();
}

int main(){

    int n;
    vector<int> heights;

    cin >> n;
    heights = vector<int>(n);

    for(int i = 0; i < n; i++)
        cin >> heights[i];

    int cost = jump(&heights);
    cout << cost << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <limits>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define x first
#define y second
#define sf scanf
#define pf printf
#define vec vector
#define pb push_back
#define mp make_pair
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define clr(a,b) memset(a,b,sizeof(a))
#define bin_cnt(x) __builtin_popcount(x)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define srep(sub,s) for(int sub=s&(s-1);sub;sub=(sub-1)&s)
#define irep(i,a) for(__typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define irrep(i,a) for(__typeof(a.rbegin()) i=a.rbegin();i!=a.rend();i++)
#define inf numeric_limits<int>::max()
#define finf numeric_limits<double>::infinity()
#define eps 1e-8
#pragma GCC optimize ("O3")
#define o3 __attribute__((optimize("O3")))
#pragma comment(linker, "/STACK:32505856")

template<class T> inline T sqr(T a) {return a*a;}
template<class T> inline int gmin(T&a,T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> inline int gmax(T&a,T b) {if(a<b){a=b;return 1;}return 0;}
inline int dcmp(const double &a) {return a>eps?1:(a<-eps?-1:0);}
struct Initializer{Initializer(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}}initializer;

#define N 200010
ll n,m;
ll p[N], q[N];
ll kn, km;
ll ans;

int main() {
    ans = kn = km = 0;
    cin >> n >> m;

    rep(i,1,n) cin >> p[i];
    rep(i,1,m) cin >> q[i];
    sort(p + 1, p + n + 1);
    sort(q + 1, q + m + 1);

    ll u=1, v=1;
    while (u <= n || v <= m) {
      if (v > m || (u <= n && (p[u] < q[v]))) {
        ans += (ll)p[u] * (m + 1 - km);
        kn++;
        u++;
      } else {
        ans += (ll)q[v] * (n + 1 - kn);
        km++;
        v++;
      }
    }

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


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main(){
  char s[16];
  scanf(" %s",s);
  int l=strlen(s),i;
  int c=0;
  for(i=0;i<l;i++)
    if(s[i]=='o')c++;
  c+=15-l;
  
  printf("%s",c>=8?"YES":"NO");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define endl "\n";
#define ll long long 
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define satyam ios_base::sync_with_stdio(false);
#define mishra cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
	satyam mishra
	int t;
	//cin>>t;
	t=1;
	while(t--)
	{
	   int n;cin>>n;
	   int h[n];
	   for(int i=0;i<n;i++)
	   {
	   	  cin>>h[i];
	   }
	   int arr[n-1];
	   arr[0]=abs(h[1]-h[0]);
	   if(n>2)
	   {
	   	  arr[1]=min(abs(h[1]-h[0])+abs(h[2]-h[1]),abs(h[2]-h[0]));
	   }
	   for(int i=2;i<n-1;i++)
	   {
          arr[i]=min(arr[i-1]+abs(h[i+1]-h[i]),arr[i-2]+abs(h[i+1]-h[i-1]));
	   }
	   cout<<arr[n-2];
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
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; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<string,ll> mp;
    string S[N];
    REP(i,N){
        cin >> S[i];
        sort ALL(S[i]);
        mp[S[i]]++;
    }
    ll ans = 0;
  	for(auto p:mp){
      	ans += p.second * (p.second-1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 16640
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, R, T; cin >> N >> R >> T;
	vector<int>ps(N);
	for (int i = 0; i < N; ++i) {
		int p; cin >> p;
		ps[i] = p;
	}
	vector<int>nplaces(N);
	vector<int>drinks(R);
	vector<int>needs(R);
	for (int t = 0; t < T; ++t) {
		for (int i = 0; i < N; ++i) {
			nplaces[i] += ps[i];
			nplaces[i] %= R;
		}
		for (int i = 0; i < N; ++i) {
			const int pl = nplaces[i];
			if (drinks[pl]) {
				drinks[pl]--;
			}
			else {
				needs[pl]++;
			}
		}
		for (int i = 0; i < N; ++i) {
			if (t) {
				const int pl = nplaces[i];
				drinks[pl]++;
				
			}
			
		}
	}
	int ans = accumulate(needs.begin(), needs.end(), 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3088
N,K,S = map(int,input().split())
ans_list= [0] * N
if S != 10**9:
    for i in range(N):
        if i < K:
            ans_list[i] = S
        else:
            ans_list[i] = 10**9
else:
    for i in range(N):
        if i < K:
            ans_list[i] = S
        else:
            ans_list[i] = 1
print(*ans_list)

Measured memory_bytes: 46524
n=str(input())
a=len(n)
N=list(n)
m=str(input())
A=len(m)
x=0
for i in range(a):
    C=[]
    for i in range(A):
        C.append(N[i])
    B=''.join(C)
    c=N[0]
    if B==m:
        x=x+1
    N.remove(c)
    N.append(c)
if x>0:
    print('Yes')
else:
    print('No')
        
    


Measured memory_bytes: 5564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);

int main()
{
	string a,b;
	cin >> a >> b;
	string c=a+b;
	int num=0,i,k=1;
	int sz=c.size();
	rev(i,sz)
	{
		num+=(c[i]-'0')*k;
		k*=10;
	}
	//num=stoi(c);
	double n=num;
	//cout << n << endl;
	double rt=sqrt(n);
	if(rt==(int)rt)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int N, x;
	cin >> N >> x;
	if(x == 1 || x == 2 * N - 1){
		cout << "No" << endl;
		return 0;
	}

	
	VI ret(2 * N - 1, -1);
	set<int> done;
	ret[N - 1] = x;
	done.insert(x);
	ret[N - 2] = x - 1;
	done.insert(x - 1);
	ret[N] = x + 1;
	done.insert(x + 1);

	if(x < N){
		ret[N - 3] = 2 * N - 1;
		done.insert(2 * N - 1);
	}
	else{
		ret[N + 1] = 1;
		done.insert(1);
	}


	int l = 1;
	REP(i, 2 * N - 1){
		if(ret[i] == -1){
			while(done.find(l) != done.end()) l++;
			ret[i] = l;
			done.insert(l);
		}
	}

	cout << "Yes" << endl;
	EACH(r, ret) cout << r << endl;


	return 0;
}


Measured memory_bytes: 11648
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=300050;
//ここまでテンプレ
//↓Binary Indexed Tree
struct BIT{
private:
	int n;
	vector<int> node;
public:
	//N要素のBITを作り、すべて0で初期化する
	//1-indexedであることに注意！！
	BIT(int N){
		node.resize(N+1,0);
		n=N;
	}
	//ノードiまでの和を計算する
	int sum(int i){
		if(!i)
			return 0;
		return node[i]+sum(i-(i&-i));
	}
	//ノードiにxを足す
	void add(int i,int x){
		if(i>n)
			return;
		node[i]+=x;
		add(i+(i&-i),x);
	}
};
//↑Binary Indexed Tree
int main(){
	int N,M;
	cin>>N>>M;
	//x=l,y=r
	//クエリ<x,0:区間,1:質問,y>
	vector<tint> Q;
	//クエリに質問を入れていく
	for(int i=1;i<=M;i++){
		for(int j=i;j<=M;j+=i){
			int a=j-i,b=j;
			Q.pb(mt(b,1,b));
			Q.pb(mt(a,1,b));
		}
	}
	sort(Q.begin(),Q.end());
	Q.erase(unique(Q.begin(),Q.end()),Q.end());
	//クエリに区間を入れる
	for(int i=0;i<N;i++){
		int l,r;
		cin>>l>>r;
		Q.pb(mt(l,0,r));
	}
	sort(Q.begin(),Q.end());
	//BIT
	BIT B(M+2);
	//クエリを処理する
	vector<unordered_map<int,int>> pam(M+2);
	for(tint T:Q){
		int a,b,c;
		tie(a,c,b)=T;
		//区間クエリなら、区間を追加する
		if(c==0){
			//S.update(b,S.getsum(b,b+1)+1);
			B.add(b+1,1);
		}
		//質問クエリなら、質問に答える
		else{
			//pam[mp(a,b)]=S.getsum(b,M+1);
			pam[a][b]=B.sum(M+1)-B.sum(b);
		}
	}
	//答えを求める
	for(int i=1;i<=M;i++){
		int ans=0;
		for(int j=i;j<=M;j+=i){
			int a=j-i,b=j;
			ans+=pam[b][b]-pam[a][b];
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 93024
#include<stdio.h>

int
main()
{	
  	int N,M,C;
  	int i,j,k;
  	int cnt=0;
  	scanf("%d %d %d",&N,&M,&C);
  	int ans[N];
  	int B[M];
  	int A[N][M];
      
  	for(i=0;i<M;i++){
      	scanf("%d",&B[i]);
    }
  	
  	for(j=0;j<N;j++){
      	for(k=0;k<M;k++){
          	scanf("%d",&A[j][k]);
        }
    	ans[j]=0;
        for(k=0;k<M;k++){
          	ans[j]+=A[j][k] * B[k];
        }
      	ans[j]+=C;
      	if(ans[j]>0){
          	cnt+=1;
        }
    }
  	printf("%d",cnt);
  
  	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int f(int n) {
  if (n < 0) return 0;
  if (n == 0 || n == 1) return 1;
  return n * f(n - 1);
}

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

  P p[n];
  rep(i, n) cin >> p[i].first >> p[i].second;

  double d[n][n];
  rep(i, n) rep(j, n) {
    double dx = p[i].first - p[j].first;
    double dy = p[i].second - p[j].second;
    d[i][j] = sqrt(dx * dx + dy * dy);
  }

  double ans = 0;
  rep(i, n) rep(j, n) { ans += d[i][j]; }

  printf("%.15f\n", (n - 1) * f(n - 2) * ans / f(n));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 200010;
vector<int> g[N];
int d[N][2], ans;
void dfs(int x, int fa) {
	for (auto y : g[x]) {
		if (y != fa) {
			dfs(y, x);
			if (d[x][1] < d[y][1] + 1)
				d[x][0] = d[x][1], d[x][1] = d[y][1] + 1;
			else
				d[x][0] = max(d[x][0], d[y][1] + 1);
		}
	}
	ans = max(ans, d[x][0] + d[x][1]);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1, 0);
	if (ans % 3 != 1) puts("First");
	else puts("Second");
	return 0;
}

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

int main()
{
	int n; cin >> n;
	int n1 = n % 10; n /= 10;
	int n2 = n % 10; n /= 10;
	int n3 = n % 10; n /= 10;
	int n4 = n % 10;
	if(n1==n2&&n1==n3&&n2==n3||n2==n3&&n2==n4&&n3==n4||n1==n2&&n1==n3&&n1==n4&&n2==n3&&n2==n4&&n3==n4)
		cout << "Yes";
	else
		cout << "No";
}


Measured memory_bytes: 3604
#include<stdio.h>
int n, k, i;
char s[11], c;
int main(void){
  scanf("%d%s%d", &n, s, &k);
  c=s[k-1];
  for(i=0; i<n; i++){
    if(s[i]==c){
      putchar(c);
    }else{
      putchar('*');
    }
  }
  puts("");
}


Measured memory_bytes: 128
n = int(input())
a = [int(i) for i in input().split()]
# 追加する数は常に偶数
# つまり奇数が偶数個あるかというだけの話
binary = 0
nonBinary = 0
for _a in a:
    if _a % 2 == 0:
        binary += 1
    else:
        nonBinary += 1
if nonBinary % 2 == 0:
    print("YES")
else:
    print("NO")

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

int main() {
  int N;
  bool flag = false;
  cin >> N;
  
  for(int i=0; i<26; i++){
    for(int j=0; j<16; j++){
      if(N == (4*i + 7*j)){
        flag = true;
        break;
      }
    }
  }
  
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

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

int main(){
  int H, W, N;
  cin >> H >> W >> N;

  int s_r, s_c;
  cin >> s_r >> s_c;

  string S, T;
  cin >> S >> T;

  int safe_h_begin = 1, safe_h_end = H + 1,
    safe_w_begin = 1, safe_w_end = W + 1;
  for(int i = N - 1; i >= 0; i--){
    // S[i], T[i - 1]
    if(S[i] == 'L'){
      safe_w_begin++;
    }else if(S[i] == 'R'){
      safe_w_end--;
    }else if(S[i] == 'U'){
      safe_h_begin++;
    }else{
      safe_h_end--;
    }
    if(safe_w_end <= safe_w_begin || safe_h_end <= safe_h_begin){
      cout << "NO" << endl;
      return 0;
    }

    if(i > 0){
    if(T[i - 1] == 'L'){
      safe_w_end = min(W + 1, safe_w_end + 1);
    }else if(T[i - 1] == 'R'){
      safe_w_begin = max(1, safe_w_begin - 1);
    }else if(T[i - 1] == 'U'){
      safe_h_end = min(H + 1, safe_h_end + 1);
    }else{
      safe_h_begin = max(1, safe_h_begin - 1);
    }
    }
    
  }

  //cout << safe_h_begin << ' ' << s_r << ' ' << safe_h_end << endl;
  //cout << safe_w_begin << ' ' << s_c << ' ' << safe_w_end << endl;
  if(s_r >= safe_h_begin && s_r < safe_h_end && s_c >= safe_w_begin && s_c < safe_w_end){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}



Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main()
{
  
  int a,b,c,k;
  cin>>a>>b>>c;
  cin>>k;
    while(k>0&&b<=a)
      {
          k--;
          b*=2;
      }

  while(c<=b&&k>0)
  {
      k--;
      c*=2;
  }
  if(a<b&&b<c)
  cout<<"Yes"<<endl;
  else
  {
      cout<<"No"<<endl;
  }
  
    return 0;
}



Measured memory_bytes: 3056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            string atcodeer = ab[0];
            string topcodeer = ab[1];

            string result = "";

            if (atcodeer == topcodeer)
            {
                result = "H";
            }
            else
            {
                result = "D";
            }

            Console.WriteLine(result);

        }
    }
}


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

using namespace std;

bool p[1000000];

int main()
{
    p[0] = p[1] = 1;
    
    for (int i = 4; i < 1000000; i += 2) p[i] = 1;
    
    for (int i = 3; i * i < 1000000; i += 2){
        if (!p[i]){
            for (int j = 3 * i; j < 1000000; j += i) p[j] = 1;
        }
    }
    
    int a, d, n;
    
    while (scanf("%d %d %d", &a, &d, &n) && a){
        int ct = 0;
        
        for (int i = a; ; i += d){
            if (!p[i]) ++ct;
            if (ct == n){
                printf("%d\n", i);
                break;
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 2164
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func modPow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if (n & 1) > 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

const MOD = 1000000007

func main() {
	sc := NewScanner()
	X, Y := sc.nextInt(), sc.nextInt()
	if (2*X-Y)%3 != 0 {
		fmt.Println(0)
		return
	}
	m := (2*X - Y) / 3
	if (Y-m)%2 != 0 {
		fmt.Println(0)
		return
	}
	n := (Y - m) / 2
	fmt.Println(modComb(m+n, n, MOD))
}

func modComb(big, small, mod int) int {
	if big < 0 || small < 0 || big < small {
		return 0
	}
	tmp := modFact(big, mod) * modInv(modFact(small, mod), mod) % mod
	return tmp * modInv(modFact(big-small, mod), mod) % mod
}

func modFact(a, mod int) int {
	res := 1
	for i := a; i > 0; i-- {
		res *= i
		res %= mod
	}
	return res
}

func modInv(a, mod int) int {
	return modPow(a, mod-2, mod)
}


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

#define LL long long

int a[1000005],b[1000005];
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n,k;
    cin>>n>>k;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int mx=sqrt(sum)+1;
    int ans=1;
    for(int i=1;i<=mx;i++)
    {
        if(sum%i==0)
        {
            bool ok=true;
            for(int j=0;j<n;j++)
            {
                b[j]=a[j]%i;
            }
            sort(b,b+n);
            int l=0,r=n-1;
            while(b[l]==0)
            {
                l++;
            }
            int need=0,lft=0,hav=0;
            while(l<r)
            {
                if(lft==0) lft=b[l]-0;
                if(hav==0) hav=i-b[r];
                if(lft==hav)
                {
                    need+=hav;
                    hav=lft=0;
                    l++,r--;
                }
                else if(lft>hav)
                {
                    need+=hav;
                    lft-=hav;
                    hav=0;
                    r--;
                }
                else
                {
                    need+=lft;
                    hav-=lft;
                    lft=0;
                    l++;
                }
                if(need>k)
                {
                    ok=false;
                }
            }
            if(l==r)ok=false;
            if(ok)
            {
                ans=max(i,ans);
            }

            int x=sum/i;
            ok=true;
            for(int j=0;j<n;j++)
            {
                b[j]=a[j]%x;
            }
            sort(b,b+n);
            l=0,r=n-1;
            while(b[l]==0)
            {
                l++;
            }
            need=0,lft=0,hav=0;
            while(l<r)
            {
                if(lft==0) lft=b[l];
                if(hav==0) hav=x-b[r];
                if(lft==hav)
                {
                    need+=hav;
                    hav=lft=0;
                    l++,r--;
                }
                else if(lft>hav)
                {
                    need+=hav;
                    lft-=hav;
                    hav=0;
                    r--;
                }
                else
                {
                    need+=lft;
                    hav-=lft;
                    lft=0;
                    l++;
                }
                if(need>k)
                {
                    ok=false;
                    break;
                }
            }
            if(l==r)ok=false;
            if(ok)
            {
                ans=max(ans,x);
            }
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

int n;
int field[21][21];

void hantei(void){
	/*
	rep(i, 21){
		rep(j, 21){
			printf("%d", field[i][j]);
		}
		printf("\n");
	}
	*/
	int sum = 0;
	rep(i, 21) rep(j, 21) sum += field[i][j];
	//printf("summm  %d\n", sum);
	if (sum == 0) printf("Yes\n");
	else printf("No\n");
	return;
}


void slove(int n){
	int x = 10, y = 10; //?????¨???????????????????????°
	rep(i, 21) rep(j, 21) field[i][j] = 0;
	rep(i, n){
		int pointx, pointy;
		cin >> pointx >> pointy;
		field[pointy][pointx] = 1;//????????????????????¨??????????????????
	}

	int meireikaisu;
	cin >> meireikaisu;
	rep(i, meireikaisu){
		string meirei;
		int kyori;
		cin >> meirei >> kyori;
		if (meirei[0] == 'N'){
			reps(j, 1, kyori + 1){
				if (field[y + j][x] == 1) field[y + j][x]--;//??¨??£????????????
			}
			y += kyori;
		}else if(meirei[0] == 'E'){
			reps(j, 1, kyori + 1){
				if (field[y][x + j] == 1) field[y][x + j]--;
			}
			x += kyori;
		}else if(meirei[0] == 'S'){
			reps(j, 1, kyori + 1){
				if (field[y - j][x] == 1) field[y - j][x]--;
			}
			y -= kyori;
		}else if(meirei[0] == 'W'){
			reps(j, 1, kyori + 1){
				if (field[y][x - j] == 1) field[y][x - j]--;
			}
			x -= kyori;
		}
	}
	hantei();
}

int main(void){
	rep(i, 1000){
		cin >> n;
		if (n == 0) break;
		slove(n);
	}
	return 0;
}

Measured memory_bytes: 2944
using System;
class Program {
    static void Main (string[] args) {
        string[] input = Console.ReadLine ().Split (' ');
        int N = int.Parse (input[0]);
        int M = int.Parse (input[1]);

        int ans = N * (N - 1) / 2 + M * (M - 1) / 2;
        Console.WriteLine (ans);
    }
}

Measured memory_bytes: 11092
A, B, C, X, Y = map(int, input().split())
 
cost_temp = float('inf')
 
for i in range(max(X,Y)+1):
    cost = i * 2 * C + A * max(0, X-i) + B * max(0, Y-i)
    if cost < cost_temp:
        cost_temp = cost
 
print(cost_temp)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int xp1,yp1,xp2,yp2;
    int q;
    cin>>xp1>>yp1>>xp2>>yp2;
    cin>>q;
    auto va = P(xp2-xp1,yp2-yp1);
    for(int i=0; i<q; i++){
        int x,y;
        cin>>x>>y;
        auto vb=P(x-xp1,y-yp1);
        Int vab=va.first*vb.first+va.second*vb.second;
        Int vaa=va.first*va.first+va.second*va.second;
        pair<double,double> oh;
        oh.first=(double)va.first*vab/vaa;
        oh.second=(double)va.second*vab/vaa;
        double xans=oh.first+xp1/1.000000000;
        double yans=oh.second+yp1/1.000000000;
        cout<<std::fixed << std::setprecision(15)<<xans<<" "<<std::fixed << std::setprecision(15)<<yans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3292
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sikakukei4_30
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nm = Console.ReadLine().Split(' ');
            string[] xtext = Console.ReadLine().Split(' ');
            string[] ytext = Console.ReadLine().Split(' ');

            int n = int.Parse(nm[0]);
            int m = int.Parse(nm[1]);


           long[] x = new long[n];
            long[] y = new long[m];
            for (int i = 0; i < n; i++)
            {
                x[i] = Convert.ToInt64(xtext[i]);
            }

            for (int j = 0; j < m; j++)
            {
                y[j] = Convert.ToInt64(ytext[j]);

            }


            long answer;
            long answerx = 0;

            for (int k = 0; k < n; k++)
            {

                answerx = answerx + (2 * (k + 1) - n - 1) * x[k];
                
            }

            long answery = 0;
            for (int l = 0; l < m; l++)
            {
                answery = answery + (2 * (l + 1) - m - 1) * y[l];
            }



            answer = ((answerx%1000000007) * (answery%1000000007)) % (1000000000 + 7);
           
            Console.WriteLine(answer.ToString());


          

           


           



        }
    }
}

Measured memory_bytes: 35404
import sys
sys.setrecursionlimit(10**7)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

x, y = map(int, input().split())
#print(gcd(x,y))
print(gcd2(x, y))


Measured memory_bytes: 5604
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#define ll long long
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e6+10;
const int maxm=2e5+10;
const int mod=1e9+7;

int n;
ll sum,k;
ll f[maxn];
struct node
{
    ll *num;
    int len;
}tree[maxn*4];
void build(int l,int r,int rt)
{
    tree[rt].len=r-l+1;
    tree[rt].num=new ll[tree[rt].len];
    if(l==r)
    {
        tree[rt].num[0]=f[l];
        return ;
    }
    int mid=(l+r)/2;
    build(l,mid,rt*2);
    build(mid+1,r,rt*2+1);
    int i=0,j=0,k=0;
    while(i<tree[rt*2].len&&j<tree[rt*2+1].len)
    {
        if(tree[rt*2].num[i]<tree[rt*2+1].num[j])
            tree[rt].num[k++]=tree[rt*2].num[i++];
        else
            tree[rt].num[k++]=tree[rt*2+1].num[j++];
    }
    while(i<tree[rt*2].len)
        tree[rt].num[k++]=tree[rt*2].num[i++];
    while(j<tree[rt*2+1].len)
        tree[rt].num[k++]=tree[rt*2+1].num[j++];
}
int querry(int ql,int qr,ll key,int l,int r,int rt)
{
    if(ql==l&&qr==r)
    {
        int c=lower_bound(tree[rt].num,tree[rt].num+tree[rt].len,key)-tree[rt].num;
        return tree[rt].len-c;
    }
    int mid=(l+r)/2;
    if(qr<=mid)
        return querry(ql,qr,key,l,mid,rt*2);
    else if(ql>=mid+1)
        return querry(ql,qr,key,mid+1,r,rt*2+1);
    else
        return querry(ql,mid,key,l,mid,rt*2)+querry(mid+1,qr,key,mid+1,r,rt*2+1);
}
int main()
{
    while(~scanf("%d %lld",&n,&k))
    {
        sum=0;
        f[0]=sum-k*(0+1);
        for(int i=1;i<=n;i++)
        {
            int t;
            scanf("%d",&t);
            sum=sum+t;
            f[i]=sum-k*(i+1);
        }
        build(1,n,1);
        ll ans=0;
        for(int i=0;i<=n-1;i++)
        {
            ans+=querry(i+1,n,f[i],1,n,1);
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 50944
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] l = new int[n];
		for(int i = 0; i < n; i++){
		    l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		// 計算
		int result = 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(l[i] == l[j] || l[j] == l[k]) continue;
		            if(l[k] < l[i]+l[j]){
		                result++;
		                //System.out.println(l[i] + " " +l[j] + " " + l[k]);
		            }
		        }
		    }
		}
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 26056
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;

const lli mod = 1000000007LL;
lli N;
vector<lli> A;

lli solve() {
  vector<lli> num(N);
  for (lli i = 0; i < N; ++i) {
    lli a = N - A[i] - 1;
    if (a < 0 || a % 2 != 0) {
      return 0;
    }
    lli pos = a / 2;
    ++num[pos];
  }
  lli res = 1;
  for (lli i = 0; i < N / 2; ++i) {
    if (num[i] != 2) return 0;
    res = res * 2 % mod;
  }
  if (N % 2 != 0 && num[N/2] != 1) {
    return 0;
  }
  return res;
}

int main() {
  cin >> N;
  A = vector<lli>(N);
  for (lli i = 0; i < N; ++i) {
    cin >> A[i];
  }
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

string s;
int a, b, c, d, x, m[5];

int main() {
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << 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);
		int N = sc.nextInt();
		
		int[] L = new int[N];
		int max = -1;
		int maxI = -1;
		for (int i = 0; i < N; i++) {
		    L[i] = sc.nextInt();
		    if (max < L[i]) {
		        max = L[i];
		        maxI = i;
		    }
		}
		
		int sumExcludedMax = 0;
		for (int i = 0; i < N; i++) {
		    if (i == maxI) continue;
		    sumExcludedMax += L[i];
		}
		
		if (max < sumExcludedMax) {
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
	}
}

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

int main()
{
  int p,j;
  p=j=2000;
  int t,i;
  for(i=0;i<3;i++){
    cin>>t;
    p=min(p,t);
  }
  for(i=0;i<2;i++){
    cin>>t;
    j=min(j,t);
  }
  cout<<p+j-50<<endl;
}

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

int main()
{
    int n, mi = 1000000, ma = -1000000;
    int a;
    long long sum=0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        mi = min(mi, a);
        ma = max(ma, a);
        sum += a;
    }
    cout << mi << " " << ma << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3128
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int i,j,k,s,z,sum=0;
    scanf("%d%d",&k,&s);
	for(i=0;i<=k;i++)
	for(j=0;j<=k;j++)
	{
	z=s-i-j;
	if(z<=k&&z>=0)
	//cout<<i<<" "<<j<<" "<<z<<endl;
	sum++;
	}
	printf("%d",sum);
	return 0;
}

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

int main(){
  int n; cin >> n;
  vector<ll> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];

  int ans = 1e9;
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }

  rep(i, n){
    rep(j, n){
      if(i == j) continue;
      ll dx = x[i] - x[j], dy = y[i] - y[j];
      int cost = 0;
      rep(k, n){
        ll tx = x[k] + dx, ty = y[k] + dy;
        cost++;
        rep(l, n){
          if(x[l] == tx && y[l] == ty) cost--;
        }
      }
      ans = min(ans, cost);
      //cout << cost << endl;
    }
  }
  cout << ans << endl;
  return 0;
}


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

const ll mod = 1e9 + 7;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 1;
    vector<vector<int>> d(n + 1, vector<int>(3));
    d[0] = {0, 0, 0};
    rep(i, n){
        rep(j, 3) d[i + 1][j] = d[i][j];
        int p = 0;
        int flag = 1;
        rep(j, 3){
            if (d[i][j] == a[i]){
                p++;
                if (flag) d[i + 1][j]++;
                flag = 0;
            }
        }
        ans *= p;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9048
def solve():
	S = input()
	T = input()
	ans_l = []

	cnt = 0
	for start in range(len(S) - len(T)+1):
		for i,t in enumerate(T):
			if S[start+i] == t or S[start+i] == '?':
				if i == len(T)-1:
					ans = S[:start].replace('?', 'a') + T + S[start+i+1:].replace('?', 'a')
					ans_l.append(ans)
					break
			else:
				break

	return ans_l
	
ans_l = solve()
if len(ans_l) > 0:
	print(sorted(ans_l)[0])
else:
	print('UNRESTORABLE')

Measured memory_bytes: 3064
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<list>
#include<vector>//可変長配列

using namespace std;

#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second

string s;
int q;
string s1, s2;

list<char>a1, a2;

int main() {
    cin >> s >> q;
    
    s1 = s;
    s2 = s;
    reverse(s2.begin(), s2.end());
    rep(i, s.size()) {
        a1.push_back(s1[i]);
        a2.push_back(s2[i]);
    }

    while (q--) {
        int ti;
        cin >> ti;
        if (ti == 1) {
            swap(a1, a2);

        }

        if (ti == 2) {
            int ci;
            char x;
            cin >> ci>>x;
            if (ci == 1) {
                //s1 = x + s1;
                //s2 = s2 + x;
                a1.push_front(x);
                a2.push_back(x);
            }
            if (ci == 2) {
               // s1 = s1 + x;
               // s2 = x + s2;
                a2.push_front(x);
                a1.push_back(x);
            }
        }
    }
    for (auto it = a1.begin(); it != a1.end(); it++)cout << (*it);
    cout << endl;
    return 0;
}


Measured memory_bytes: 19584
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x :: xs = List.fill(sc.nextInt())(sc.nextInt())
  val (_, count) = xs.foldLeft(x -> 1) {
    case ((l, count), r) => r.max(l) -> (count + (if (l <= r) 1 else 0))
  }
  println(count)
}


Measured memory_bytes: 55492
#include<stdio.h>

int Binarysearch(int);

int S[100000],T[50000],n,q;

int main(){

  int i,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){

    scanf("%d",&S[i]);

  }

  scanf("%d",&q);

  for(i=0;i<q;i++){

    scanf("%d",&T[i]);

  }

  for(i=0;i<q;i++){

    count+=Binarysearch(T[i]);

  }

  printf("%d\n",count);

  return 0;

}

int Binarysearch(int key){

  int left=0,right=n,mid;


  while(left<right){

    mid=(left+right)/2;

    if(key==S[mid])return 1;

    if(key>S[mid]) left=mid+1;

    else if(key<S[mid]) right=mid;

  }

  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e18+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string a; cin >> a;
    ll n = a.size();
    vector<ll> c(26,0);
    rep(i,0,n){
        c[a[i]-'a']++;
    }
    ll ans = n*(n-1)/2;
    rep(i,0,26){
        ans -= (c[i]-1)*c[i]/2;
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 720