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

using namespace std;

int main(){
string A, B;
  cin >> A >> B;
  //入力終了

  //AとBの桁数
  int a = A.size(), b = B.size();
  
  //Aの方が桁数が小さい
  if(a<b)
    cout << "LESS" << endl;
  //Aの方が桁数が大きい
  else if(a>b)
    cout << "GREATER" << endl;
  //桁数は同じ
  else{
	int i = -1, j = -1;
	//文字列が同じところはスルー
    while(A[++i] == B[++j])
      //最後までいったら文字列は等しい
      if(i == a){
       cout << "EQUAL" << endl;
	   return 0;
      }
    
    if(A[i] < B[j])
      cout << "LESS" << endl;
    else
      cout << "GREATER" << endl;
  }

return 0;	
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int h, w;
int c[10][10];
int ans = 0;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> h >> w;
    rep(i, 10) rep(ii, 10) cin >> c[i][ii];
    
    rep(i, 10) {
        rep(ii, 10) {
            rep(iii, 10) {
                c[ii][iii] = min(c[ii][iii], c[ii][i] + c[i][iii]);
            }
        }
    }
    
    rep(x, w) {
        rep(y, h) {
            int a;
            cin >> a;
            ans += c[abs(a)][1];
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Union_Find_Tree{
	public:
	vi p,r,s;
	Union_Find_Tree(int n){
		p=r=vi(n);
		s=vi(n,1);
		for(int i=0;i<n;i++) p[i]=i;
	}
	int Par(int x){
		if(p[x]==x) return x;
		return p[x]=Par(p[x]);
	}
	int Size(int x){return s[Par(x)];}
	bool Unite(int x,int y){
		x=Par(x);
		y=Par(y);
		if(x==y) return 0;
		if(r[x]<r[y]){
			p[x]=y;
			s[y]+=s[x];
		}
		else{
			p[y]=x;
			s[x]+=s[y];
			if(r[x]==r[y]) r[x]++;
		}
		return 1;
	}
	bool Same(int x,int y){return Par(x)==Par(y);}
};

int n;
vp b;

int main(){
	cin>>n;
	b=vp(n);
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		b[x-1]={y,i};
	}
	vp a;
	Union_Find_Tree uft(n);
	stack<P> st;
	st.push({inf,0});
	for(int i=0;i<n;i++){
		int x=b[i].first,mn=x;
		while(st.top().first<x){
			mn=min(mn,st.top().first);
			uft.Unite(b[i].second,st.top().second);
			st.pop();
		}
		st.push({mn,b[i].second});
	}
	for(int i=0;i<n;i++) cout<<uft.Size(i)<<endl;
}

Measured memory_bytes: 7188
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<ctime>
#include<bitset>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return f*x;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
LL dep[MAXN+5];
int ncnt=1,G[MAXN+5][2];
void Insert(char S[]){
	int p=1;
	for(int i=1;S[i];i++){
		if(!G[p][S[i]-'0'])
			G[p][S[i]-'0']=++ncnt,dep[ncnt]=dep[p]-1;
		p=G[p][S[i]-'0'];
	}
	return ;
}
char S[MAXN+5];
int main(){
	int n=read();dep[1]=read();
	for(int i=1;i<=n;i++){
		scanf("%s",S+1);
		Insert(S);
	}
	LL ans=0;
	for(int i=1;i<=ncnt;i++)
		if((!G[i][0]&&G[i][1])||(!G[i][1]&&G[i][0]))
			ans^=dep[i]&-dep[i];
	if(!ans) puts("Bob");
	else puts("Alice");
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    ll n, a;
    cin >> n;
    ll odd_sum = 0, even_sum = 0;
    ll odd_cost = 0, even_cost = 0;
    rep(i, n) {
        cin >> a;
        if (i % 2) { // odd
            if (odd_sum + a > 0) odd_sum += a;
            else {
                odd_cost += abs(1 - (odd_sum + a));
                odd_sum = 1;
            }

            if (even_sum + a < 0) even_sum += a;
            else {
                even_cost += abs(-1 - (even_sum + a));
                even_sum = -1;
            }
        } else {
            if (odd_sum + a < 0) odd_sum += a;
            else {
                odd_cost += abs(-1 - (odd_sum + a));
                odd_sum = -1;
            }

            if (even_sum + a > 0) even_sum += a;
            else {
                even_cost += abs(1 - (even_sum + a));
                even_sum = 1;
            }
        }
    }
    cout << min(odd_cost, even_cost) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)
#define MOD (10e9 + 7)

int main(void){
    int R;
    cin >> R;
    double pi = 3.14159;
    cout << (2*R*pi) << endl;

}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,l;
    cin >> n >> l; 
    vector<string> hoge(n);

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

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

    for(int i=0;i<n;i++) 
        cout << hoge[i];

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>

using int64 = long long;

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

    int x1, y1, x2, y2;
    std::cin >> x1 >> y1 >> x2 >> y2;

    int a = x2 - x1,
        b = y2 - y1;
    std::cout << x2 - b << " " << y2 + a << " " 
              << x2 - b - a << " " << y2 + a - b << std::endl;

    return 0;
}


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

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define mem(x,i) memset((x),(i),sizeof((x)))
#define odd(x) ((x)&1)
#define LG(x) (int)log2((x))

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

mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int gcd(int aaa,int bbb){
	return (bbb==0 ? aaa : gcd(bbb,aaa%bbb));
}
int lcm(int aaa,int bbb){
	return (aaa/gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**
const int N = 1e5+10;

int n;
int a[N][4];
int dp[N][4];

void solve(){
	cin >> n;
	rep(i,1,n+1)
		rep(j,1,4)
			cin >> a[i][j];
	rep(i,1,n+1){
		rep(j,1,4){
			rep(k,1,4){
				if(k==j)
					continue;
				dp[i][j] = max(dp[i][j],dp[i-1][k]+a[i][j]);
			}
		}
	}
	cout << max(dp[n][1],max(dp[n][2],dp[n][3])) << '\n';
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}


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

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

const ll LINF = 1LL << 60;
const int MAX_N = 1e5;

int main() {
  ll h[110000]; 
  ll dp[110000]; 
  int N, K; cin >> N >> K;
  REP(i, N) cin>>h[i];
  REP(i, 110000) dp[i] = LINF;

  dp[0]=0;

  for(int now=0; now < N; ++now){
    for(int dist=1; dist<=K; ++dist) {
      chmin(dp[now+dist],  dp[now]+abs(h[now]-h[now+dist]));
    }
  }
  cout << dp[N-1] << endl;
}


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

#define ll long long
using namespace std;
#define maxn 100000+100


int main() {
    int n;
    cin >> n;
    double sum = 0;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        sum += 1.0 / tmp;
    }
    printf("%.7lf\n", 1.0 / sum);


    return 0;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
dp = np.array([0]* 100010)
for i,j in enumerate(map(int,input().split())):
    if j -1 < 0: dp[j] += 1;dp[j+1] +=1
    else:dp[j] += 1;dp[j-1] += 1;dp[j+1] += 1
print(np.max(dp))

Measured memory_bytes: 22032
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

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

int main() {
    int n; cin >> n;
    vector<vector<int>> graph(n);
    vector<pair<int, int>> edge(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        int a, b; cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
        edge[i].first = a;
        edge[i].second = b;
    }

    int k = 0;
    vector<bool> visited(n);
    queue<int> que;
    map<pair<int, int>, int> color;
    vector<int> used_color(n);
    visited[0] = true;
    que.push(0);
    while (!que.empty()) {
        int from = que.front(); que.pop();
        int cur = 1;
        k = max(k, (int)graph[from].size());
        for (int to : graph[from]) {
            if (visited[to]) continue;
            if (cur == used_color[from]) ++cur;
            used_color[to] = color[make_pair(from, to)] = color[make_pair(to, from)] = cur++;
            visited[to] = true;
            que.push(to);
        }
    }

    cout << k << endl;
    for (const auto& e : edge) {
        cout << color[e] << endl;
    }
    return 0;
}

Measured memory_bytes: 19712
#include<bits/stdc++.h>
#define dd(x) cout<<#x<<" = "<<x<<" "
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define sz(x) int(x.size())
#define All(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef priority_queue<int> BQ;
typedef priority_queue<int,vector<int>,greater<int> > SQ;
const int maxn=3e5+10,mod=1e9+7,INF=0x3f3f3f3f;
map<int,int> cnt;
int a[maxn];
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	ll ans=0;
	for (int i=1;i<=n;++i){
		ans+=cnt[i-a[i]];
		cnt[a[i]+i]++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 21608
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

int64_t solve(int64_t r, int64_t g, int64_t b, int64_t n) {
  int64_t ret = 0;
  for (int rr = 0;; ++rr) {
    auto const rrr = rr * r;
    if (rrr > n) {
      break;
    }
    for (int gg = 0;; ++gg) {
      auto const ggg = gg * g + rrr;
      if (ggg > n) {
        break;
      }
      if ((n - ggg) % b != 0) {
        continue;
      }
      ret++;
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t r;
  std::cin >> r;
  int64_t g;
  std::cin >> g;
  int64_t b;
  std::cin >> b;
  int64_t n;
  std::cin >> n;
  auto const res = solve(r, g, b, n);
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<random>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<unordered_map>
#include<time.h>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef long double ld;
signed main() {
	string s;
	cin >> s;
	bool a = 0, b = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'C') a = 1;
		if (a&&s[i] == 'F') b = 1;
	}
	if (b) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
bool VIS[N];
int main()
{   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
   int  n=s.size();
    if(n==1) cout<<"1";
    else if(n==2)
    {
        if(s[0]!=s[1]) cout<<"2";
        else cout<<"1";
    }
    else
    {
        int k=1;
        int prev=1;
        int i=1;
        while(i<n)
        {
            if(s[i]!=s[i-1]) {k++;i++;prev=1;}
            else
            {
                if(prev==2) {k++;i++;prev=1;}
                else
                {
                    k++;i+=2;prev=2;
                }
            }
            //cout<<k<<" "<<i<<"\n";
        }
        if(i>n) k-=1;
        cout<<k;
    }

}


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

int main(){
  int N,K;
  cin>>N>>K;
  int ans = 0;
  for(int i=0;i<N;i++){
    int h;
    cin>>h;
    if(h>=K)ans++;
  }

  cout<<ans<<endl;
}


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

int main(){
    int n , k , ans = 0;
    string s;
    cin >> n >> k >> s;
    vector <int> v;
    v.push_back(0);
    int j = 0;
    for(int i = 0; i < n; i++){
        if(k<=0 && s[i] == '0' && s[i-1]=='1'){
            ans = max(ans , i - v[j]);
            //cout << i << " " << v[j] << endl;
            j++;
            continue;
        }
        if(i>0 && s[i-1]=='0' && s[i] == '1'){
            v.push_back(i);
            //cout << i << endl;
            k--;
        }
    }
    if(k<=0){
        ans = max(ans , n  - v[j]);
    }
    if(k>0){
        ans = n;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
int N, A, B, C;
int l[10];
int ans = INF;
void dfs(int cnt,int a,int b,int c,int mp) {
	if (cnt == N) {
		if (a == 0 || b == 0 || c == 0) {
			return;
		}
		else {
			mp += abs(a - A) + abs(b - B) + abs(c - C);
			ans = min(ans, mp);
			return;
		}
	}

	if (a == 0)dfs(cnt + 1, a + l[cnt], b, c, mp);
	else dfs(cnt + 1, a + l[cnt], b, c,mp + 10);

	if (b == 0)dfs(cnt + 1, a, b + l[cnt], c, mp);
	else dfs(cnt + 1, a, b + l[cnt], c,mp + 10);

	if (c == 0)dfs(cnt + 1, a, b, c + l[cnt], mp);
	else dfs(cnt + 1, a, b, c + l[cnt], mp + 10);

	dfs(cnt + 1, a, b, c, mp);
}
int main() {
	cin >> N >> A >> B >> C;
	for (int i = 0; i < N; ++i)cin >> l[i];
	dfs(0, 0, 0, 0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

string s;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> s;
  vii cnt(26, 0);
  rep(i, 0, s.size()) {
    cnt[s[i] - 'a']++;
  }
  rep(i, 0, 26) {
    if (cnt[i] == 0) {
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}



Measured memory_bytes: 512
n = int(input())
w = [input() for i in range(n)]
x = w[0][0]
s = set()
flag = True
for wi in w:
    if wi[0] != x or wi in s:
        flag  = False
        break
    else:
        x = wi[-1]
        s.add(wi)
print("Yes" if flag else "No")

Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


// a と b の最大公約数を返す
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}


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



// 素数判定
bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}


// 約数列挙
vector<ll> enum_divisors(ll N) {
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll>> res;
    for(ll i = 2; i * i <= N; i++){
        if(N % i != 0)  continue;
        ll ex = 0;

        while(N % i == 0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1)  res.push_back({N, 1});
    return res;
};


int main(){
    int n;  cin >> n;
    if(n % 10 == 7 || (n / 10) % 10 == 7 || (n / 100) % 10 == 7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, M;
int a[310][310];
bool t[310];
int num[310];

int main() {
	cin >> N >> M;

	rep(i, N) {
		rep(j, M) {
			cin >> a[i][j];
			--a[i][j];
		}
	}

	rep(i, M) t[i] = 1;

	int zan = M;
	int ret = N;

	while (true) {
		memset(num, 0, sizeof(num));

		rep(i, N) {
			rep(j, M) {
				if (t[a[i][j]]) {
					++num[a[i][j]];
					break;
				}
			}
		}

		pii p = mp(-1, -1);

		rep(i, M) {
			p = max(p, mp(num[i], i));
		}

		if (p.fi == 0) {
			break;
		}

		int c = p.fi;
		ret = min(ret, c);

		t[p.se] = 0;
		--zan;
	}

	cout << ret << endl;

	return 0;
}

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

int main() {
  int n, m, x, y;
  std::cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++) {
    int xx;
    std::cin >> xx;
    x = std::max(x, xx);
  }
  for (int i = 0; i < m; i++) {
    int yy;
    std::cin >> yy;
    y = std::min(y, yy);
  }
  std::cout << (y - x >= 1 ? "No War" : "War") << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct unionfind{
	vector<int> data;
	vector<int> size;
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i);
			size.push_back(1);
		}
	}
	
	int find(int x){
		if(data[x]==x)return x;
		return data[x]=find(data[x]);
	}
	
	bool unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return false;
		data[x]=y;
		size[y]+=size[x];
		return true;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
	
	int get_size(int x){
		int X = find(x);
		return size[X];
	}
};


int main(){
	int N,M;
	cin>>N>>M;
	
	vector<int> p(N);
	for(int i=0;i<N;i++){
		cin>>p[i];
		p[i]--;
	}
	
	unionfind uf(N);
	
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		uf.unite(a,b);
	}
	
	int ans = 0;
	for(int i=0;i<N;i++){
		if(uf.check(i,p[i]))ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 1660
s = input()
K = int(input())


if s.count(s[0]) == len(s):
    print(len(s)*K//2)
elif len(s) >= 3:
    ans1 = 0
    ans2 = 0
    use = [True]*len(s)
    use2 = [True]*len(s)
    for i in range(len(s)-1):
        if use[i+1] and use[i]:
            if s[i+1] == s[i]:
                ans1 += 1
                use[i+1] = False

    if use[-1] and use2[0]:
        if s[-1] == s[0]:
            ans2 += 1
            use2[0] = False

    for i in range(len(s)-1):
        if use2[i+1] and use2[i]:
            if s[i+1] == s[i]:
                ans2 += 1
                use2[i+1] = False

    print(ans1+ans2*(K-1))

else:
    if len(s) == 1:
        print(K//2)
    else:
        if s[0] == s[1]:
            print(K)
        else:
            print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int n;
vector<int> graph[110];
int visited[110],dist[110];
int main()
{
    cin >>n;
    rep(i,n){
        int u;
        
        cin >> u;
        u--;
        int k;
        cin >> k;
        rep(j,k){
            int v;
            cin >> v;
            v--;
            graph[u].push_back(v);
            
        }

    }
    queue<int> q;
    
    q.push(0);
    visited[0] = 1;
    while(!q.empty()){
        auto now = q.front();q.pop();
        
        for(auto next :graph[now]){
            if(visited[next])continue;
            dist[next] = dist[now] +1;
            q.push(next);
            visited[next] = 1;
        }
    }

    rep(i,n){
        if (i && dist[i] == 0)cout << i+1 << " " << -1 << endl;
        else cout << i+1 << " " <<  dist[i] << endl; 
    }
    

    return 0;
}


Measured memory_bytes: 3136
fun main(args: Array<String>) {
    val (N, A, B) = listOfInt()
    fun pow2(n: Int): ModInt {
        if (n == 0) return ModInt(1)
        var x = pow2(n / 2)
        x *= x
        if (n % 2 == 1) x *= 2
        return x
    }
    fun Combi(n: Int, a: Int): ModInt {
        var x = ModInt(1)
        var y = ModInt(1)
        repeat(a) { i ->
            x *= n - i
            y *= i + 1
        }
        return x / y
    }
    var ans = (pow2(N) - 1) - Combi(N, A) - Combi(N, B)
    println(ans.toString())
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)


data class ModInt(private var v: Long) {
    companion object { private const val MOD = 1000000007L }
    init { this.v %= MOD }
    constructor(n: Int): this(n.toLong())
    operator fun plus(other: Int) = ModInt((this.v + other) % MOD)
    operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)
    operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)
    operator fun times(other: Int) = ModInt(this.v * other % MOD)
    operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)
    operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)
    private fun pow(a: Long, b: Long): Long {
        if (b == 0L) return 1L
        if (b % 2 == 0L) {
            val d = pow(a, b / 2)
            return (d * d) % MOD
        }
        return a * pow(a, b - 1) % MOD
    }
    override fun toString() = this.v.toString()
}



Measured memory_bytes: 42816
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
R = []
D = []
interval = []
for _ in range(n - 1):
    c, s, f = LI()
    R += [c]
    D += [s]
    interval += [f]


for start in range(n - 1):
    t = 0
    for j in range(start, n - 1):
        d, r, f = D[j], R[j], interval[j]
        if t <= D[j]:
            t = D[j] + R[j]
        else:
            t = D[j] + (t - D[j]) // interval[j] * interval[j] + bool((t - D[j]) % interval[j]) * interval[j] + R[j]
    print(t)
print(0)



Measured memory_bytes: 41200
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
	int S;
	cin >> S;
	int h = S / 3600;
	S %= 3600;
	int m = S / 60;
	S %= 60;
	int s = S;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


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

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int>D( N );
	for( size_t i = 0; i < N; i++ ) {
		cin >> D[i];
	}
	double maxans = 1, minans = 0;
	for( size_t idx = 0; idx < 27; idx++ ) {
		double midans = ( maxans + minans ) / 2;
		set<int>prev;
		prev.insert( 1 );
		for( size_t i = 0; i < N; i++ ) {
			double minvalue = D[i] * ( 1. - midans );
			double maxvalue = D[i] * ( 1. + midans );
			set<int>next;
			for( auto one : prev ) {
				for( int j = minvalue / one + 1; j <= maxvalue / one; j++ ) {
					next.insert( j*one );
				}
			}
			prev = next;
		}
		if( prev.size() ) {
			maxans = midans;
		} else {
			minans = midans;
		}

	}
	cout << fixed << setprecision( 20 ) << minans << endl;
}

Measured memory_bytes: 10836
import math
import itertools


def is_prime(n):
    if n % 2 == 0 and n > 2:
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))


X = int(input())
for n in itertools.count(start=X):
    if is_prime(n):
        print(n)
        break

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

int main() {
    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int, int>> pos(h * w);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int a;
            cin >> a;
            a--;
            pos[a] = {i, j};
        }
    }

    vector<vector<int>> cost(d, vector<int>(h * w / d + 5));
    // cost[i][j]: あまり i のルートで d * j + i まで進んだときのコスト
    for (int i = 0; i < d; i++) {
        cost[i][0] = 0;
        for (int j = 1; d * j + i < h * w; j++) {
            int prev = d * (j - 1) + i, now = prev + d;
            cost[i][j] = cost[i][j - 1] + abs(pos[prev].first - pos[now].first) + abs(pos[prev].second - pos[now].second);
        }
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        cout << cost[r % d][r / d] - cost[l % d][l / d] << endl;
    }
    return 0;
}

Measured memory_bytes: 6016
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	s, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	w, _ := strconv.Atoi(sc.Text())
	if s <= w {
		fmt.Println("unsafe")
	}else{
		fmt.Println("safe")
	}
}


Measured memory_bytes: 1756
// ???????????????????¬¢?§?????????£????????? 
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2018
// ????????????????¨?????????????20????????????????????????????????? 20???????????????????????´??????15?????????
//C++??§??????35??? = 90???

#include <iostream>
using namespace std;

#define NUM 100

int main(){
  int N,M,P; //??????????????¨??????
  double gold = 0; //?¨????????????¨
  double give; //?¨????????????¨
  double pull; //?¨????????????¨
  double get[NUM]; //????????£?????????????????????
  int num[NUM]; //?¨????????????¨
  int count = 0;
  int i;


  while(1){
    count++;
    cin >> N >> M >> P;
    
    if ((N==0 && M==0 && P==0) || count > 100){ //?????????????????????100??\??????0 0 0
      count--; //??¨????????°?????????????????§???????????????????????°??????
      break;
    }

    for (i=0; i < N ;i++){ ////?????????????????´??????????????¨???????¨????
      cin >> num[i];
      gold += num[i] * 100;;
    }
    
    // ?¨??????????????????§???
    give = gold / num[M-1]; //M-1??¨????????????i?????????????§??????£???????????????
    pull = give * P /100;
    get[count - 1] = give - pull; //count-1??¨????????????count???0????????§??????
    gold = 0; //?????????             //??????????§?????????????
    //???????????§
    
    if (num[M-1] == 0){ //????????????????????¨??????????????????0?????¨?????????????????????????????°????????????
      get[count - 1] = 0;
    }
    
    for (i=0; i < N ;i++){ //?????????
      num[i] = 0;
    }
  }

  for (i=0; i < count ;i++){ //output
    cout << (int)get[i] << "\n";
  }
  return 0;
}
  

    

    
  

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

int main() {
  int n,m;
  cin>>n>>m;
  int s=0;
  int q=0;
  vector<int> a(n);
  for (int i=0;i<n;++i) {
    cin>>a[i];
    s+=a[i];
  }
  for (int i=0;i<n;++i) {
    if(a[i]*4*m>=s) {
      q+=1;
    }
  } 
  if (q>=m) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}




Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int Year;
    int month,day;
    int h;
    char *w[7] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    while (1){
        scanf("%d %d", &month, &day);
        if (month == 0){
            break;
        }
        Year = 2004;
        h = 0;

        if (month == 1 || month == 2){
            Year = Year - 1;
            month += 12;
        }
        h = (Year + Year / 4 - Year / 100 + Year / 400 + (13 * month + 8) / 5 + day) % 7;
        printf("%s\n", w[h]);
    }
    return (0);
}


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

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

  if(a==0){
    cout << b/x + 1;
    return 0;
  }

  
  ll ans = (b/x) - (a-1)/x;

  cout << ans;
   return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

ll n,a[200010];
int main(){
  cin >> n;
  vector<ll> s(n+1);
  s[0] = 0;
  rep(i,n){
    cin >> a[i];
    s[i+1] = s[i] + a[i];
  }
  sort(all(s));
  ll cnt=1,ans=0;
  rep(i,n+1){
    if(i!=0){
      if(s[i]==s[i-1]){
        cnt++;
      }else{
        ans += cnt*(cnt-1)/2;
        cnt=1;
      }
    }
  }
  ans += cnt*(cnt-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 3328
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  constexpr auto SELECTED = -1;

  array<array<ll, 3>, 3> A;
  REP(i, 3) {
    REP(j, 3) { cin >> A[i][j]; }
  }
  ll N;
  cin >> N;
  REP(i, N) {
    ll B;
    cin >> B;
    REP(i, 3) {
      REP(j, 3) {
        if (A[i][j] == B) {
          A[i][j] = SELECTED;
        }
      }
    }
  }

  // Row0
  if (A[0][0] == SELECTED && A[1][0] == SELECTED && A[2][0] == SELECTED) {
    cout << "Yes" << endl;
  }
  // Row1
  else if (A[0][1] == SELECTED && A[1][1] == SELECTED && A[2][1] == SELECTED) {
    cout << "Yes" << endl;
  }
  // Row2
  else if (A[0][2] == SELECTED && A[1][2] == SELECTED && A[2][2] == SELECTED) {
    cout << "Yes" << endl;
  }
  // Col0
  else if (A[0][0] == SELECTED && A[0][1] == SELECTED && A[0][2] == SELECTED) {
    cout << "Yes" << endl;
  }
  // Col1
  else if (A[1][0] == SELECTED && A[1][1] == SELECTED && A[1][2] == SELECTED) {
    cout << "Yes" << endl;
  }
  // Col2
  else if (A[2][0] == SELECTED && A[2][1] == SELECTED && A[2][2] == SELECTED) {
    cout << "Yes" << endl;
  }
  // Diagonal0
  else if (A[0][0] == SELECTED && A[1][1] == SELECTED && A[2][2] == SELECTED) {
    cout << "Yes" << endl;
  }
  // Diagonal1
  else if (A[0][2] == SELECTED && A[1][1] == SELECTED && A[2][0] == SELECTED) {
    cout << "Yes" << endl;
  }
  // Nothing
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
s = input()
t = input()
temp = 0
for i in range(len(s)-len(t)+1):
  ns = s[i:i+len(t)]
  cnt = 0
  for k,l in zip(ns,t):
    if k==l:
      cnt += 1
  temp = max(cnt,temp)
print(len(t)-temp)

Measured memory_bytes: 9120
#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

struct pos{
    int row;
    int col;
    pos(){}
    pos(int r, int c){
        row = r;
        col = c;
    }
};

int dc[4] = {1, 0, -1, 0};
int dr[4] = {0, 1, 0, -1};
char grid[1001][1001];
bool vis[1001][1001];
int R, C;

vector<pos> source;

bool out(int r, int c){return r<0 || c<0 || r>=R || c>=C;}

void mark_source()
{
    for(int i=0; i<R; i++){
        for(int j=0; j<C; j++){
            if(grid[i][j] == '#') source.push_back(pos(i, j));
        }
    }
}

int blackout()
{
    if(source.empty() || (R == 1 && C == 1)) return 0;

    queue<pos> Q;
    queue<pos> layer;
    int turn_count = 0, new_row, new_col;

    for(auto i : source){
        vis[i.row][i.col] = true;
        Q.push(i);
    }

    while(!Q.empty()){
        
        layer = Q;
        Q = {};

        while(!layer.empty()){
            for(int i=0; i<4; i++){
                new_row = layer.front().row + dr[i];
                new_col = layer.front().col + dc[i];

                if(out(new_row, new_col) || vis[new_row][new_col]) continue;

                Q.push(pos(new_row, new_col));
                vis[new_row][new_col] = true;
            }
            layer.pop();
        }
        
        if(!Q.empty()) turn_count++;
    }

    return turn_count;
}

int main()
{
    memset(vis, false, sizeof(vis));
    cin >> R >> C;

    for(int i=0; i<R; i++){
        for(int j=0; j<C; j++){
            cin >> grid[i][j];
        }
    }

    mark_source();
    cout << blackout() << "\n";
    return 0;
}

Measured memory_bytes: 25704
from typing import Set


class UnionFind:
    """Union-Find: O(α(N))"""

    __slots__ = ["_data_size", "_first_idx", "_parents"]

    def __init__(self, data_size: int, is_zero_origin: bool = True) -> None:
        self._data_size = data_size
        self._first_idx = 0 if is_zero_origin else 1
        self._parents = [-1] * (data_size + self._first_idx)

    def __getitem__(self, x: int) -> int:
        """Find the group (root) of vertex x."""
        if self._parents[x] < 0:
            return x
        self._parents[x] = self[self._parents[x]]
        return self._parents[x]

    def __len__(self) -> int:
        """Count the number of groups (roots)."""
        return len(self.groups)

    @property
    def groups(self) -> Set[int]:
        """Return the set of groups (roots)."""
        return {
            self[x] for x in range(self._first_idx, self._data_size + self._first_idx)
        }

    def is_connected(self, x: int, y: int) -> bool:
        """Return whether two vertices x and y are connected or not."""
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y."""
        x, y = self[x], self[y]
        if x == y:
            return
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x

    def unite_all(self, *vertices: int) -> None:
        """Unite the groups of all of the given vertices."""
        x = vertices[0]
        for y in vertices[1:]:
            self.unite(x, y)

    def get_size(self, x: int) -> int:
        """Return the size of the group vertex x belongs."""
        return -self._parents[self[x]]


def unionfind():
    # https://judge.yosupo.jp/problem/unionfind
    N, Q, *TUV = map(int, open(0).read().split())
    tree = UnionFind(N)
    res = []
    for t, u, v in zip(*[iter(TUV)] * 3):
        if t:
            res.append(int(tree.is_connected(u, v)))
        else:
            tree.unite(u, v)
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    unionfind()


Measured memory_bytes: 60872
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A == B) {
    cout << C << endl;
  } else if (B == C) {
    cout << A << endl;
  } else {
    cout << B << endl;
  }
  return 0;
}

Measured memory_bytes: 3612
n=int(input())
a=list(map(int,input().split()))
alice=0
bob=0
#降順ソート
a.sort()
a.reverse()

for i in range(int(n/2)):
        alice+=int(a[2*i])
        bob+=int(a[2*i+1])
if n%2==1:
        alice+=int(a[n-1])

ans=alice-bob
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int x, y;
	cin >> x >> y;
	cout << gcm(x, y) << endl;
}


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

int compute(int x, int y, int z){
    return x*x + y*y + z*z + z*y + x*y + z*x;
}

void solve(){
    int n;
    cin>>n;
    vector<int> ans(n+1, 0);
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                int val = compute(i,j,k);
                if(val>n)break;
                ans[val]++;
            }
        }
    }
    for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
    return;
}

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


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
const int MR=1e6+10;
typedef long long LL;

map<LL,LL> myset;

int main() {
	LL n,a,cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		cnt+=myset[a-i];
		if(myset.count(-a-i)){
			myset[-a-i]+=1;
		}
		else{
			myset[-a-i]=1;
		}
	}
	cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 26140
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>

#define MAX_N 50
#define MAX_M 50

using namespace std;

int n,m;
string s[MAX_N];

void solve() {
	bool b = true;
	const int x[4] = { 1,-1,0,0 }, y[4] = { 0,0,1,-1 };
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '#') {
				bool B = false;
				for (int d = 0; d < 4; d++) {
					int nx = j + x[d], ny = i + y[d];
					if (nx >= 0 && nx < m && ny >= 0 && ny < n)if (s[ny][nx] == '#') B = true;
				}
				if (!B) b = false;
			}
		}
	}
	if (b) cout << "Yes" << endl;
	else cout << "No" << endl;
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 256
const lines=readlines()
const N=parse(Int,shift!(lines))
const up=zeros(Int,N)
const down=zeros(Int,N)
function add(A,i,a)
	while i<=N
		A[i]+=a
		i+=i&-i
	end
end
function sum(A,i)
	ret=0
	while i>0
		ret+=A[i]
		i-=i&-i
	end
	ret
end
const mod=998244353
const F=zeros(Int,N+1)
function bsearch(A,x)
	L=0
	R=N
	while R-L>1
		M=div(L+R,2)
		if A[M]>=x
			R=M
		else
			L=M
		end
	end
	R
end
function main()
	F[1]=1
	X=Int[]
	Y=Int[]
	xy=Pair{Int,Int}[]
	for i=1:N
		F[i+1]=F[i]*2%mod
		x,y=map(x->parse(Int,x),split(shift!(lines)))
		push!(X,x)
		push!(Y,y)
		push!(xy,x=>y)
	end
	sort!(X)
	sort!(Y)
	for i=1:N
		x=bsearch(X,xy[i].first)
		y=bsearch(Y,xy[i].second)
		xy[i]=x=>y
		add(down,y,1)
	end
	sort!(xy)
	ans=0
	for i=1:N
		y=xy[i].second
		add(down,xy[i].second,-1)
		a=sum(up,y)
		b=i-1-a
		c=sum(down,y)
		d=N-i-c
		aX=(F[a+1]+F[d+1]+mod-1)%mod
		aY=(F[b+1]+F[c+1]+mod-1)%mod
		ans=(ans+F[N+1]-aX*aY%mod+mod)%mod
		add(up,y,1)
	end
	println(ans)
end
main()

Measured memory_bytes: 166668
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;


int main(void)
{
	string s; cin >> s;
	for (int i = 0; i<s.length(); i += 2)cout << s[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];
ll ans[310][310];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll h, w, k;
	cin >> h >> w >> k;
	ll res = 1;
	bool flag = false;
	bool tateflag = true;
	ll tate = INF;
	rep(i, h) {
		bool tateflag2 = false;
		rep(j, w) {
			cin >> c[i][j];
			if (c[i][j] == '#') {
				tateflag2 = true;
				if (flag)res++;
				else {
					flag = true;
				}
			}
			ans[i][j] = res;
			if (j == w - 1) {
				if (tateflag2)res++;
				flag = false;
			}
		}
		if (tateflag2 == false) {
			if (i != 0) {
				rep(j, w) {
					ans[i][j] = ans[i - 1][j];
				}
			}
		}
		else {
			if (tate == INF)tate = i;
		}
	}
	rep(i,h) {
		bool tateflag2 = false;
		rep(j, w) {
			if (c[i][j] == '#')tateflag2 = true;
		}
		if (tateflag2 == false) {
			rep(j, w) {
				ans[i][j] = ans[tate][j];
			}
		}
		else {
			break;
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << ans[i][j];
			if (j != w - 1)cout << " ";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 4396
A, B, C, X, Y = gets.split.map(&:to_i)
ret = 10000000000
n = [X,Y].max
(n).downto(0) do |c_|
    c = c_ * 2
    a = [0, X - c.div(2)].max
    b = [0, Y - c.div(2)].max
    ret = [ret, a*A + b*B + c*C].min
end
puts ret

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

int main() {
  int x, y;
  cin >> x >> y;
  bool ans = false;
  if ((y-2*x) % 2==0 && (y-2*x) >= 0) {
    if (x -(y-2*x)/2 >= 0) {
      ans = true;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636