akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,a[5];
    for(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    if((a[0]+a[1])==a[2])
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}



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

subs = []

for i in range(0,K + 1):
  for j in range(0,len(s) - i):
    sub = s[j:j + i + 1]
    subs.append(sub)
    
subs = sorted(list(set(subs)))

print(subs[K - 1])

Measured memory_bytes: 5428
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(1<=a && a<=13 && 1<=b && b<=13 && 1<=c && c<=13 && a+b+c>=22)
{
printf("bust\n");
}
else{
printf("win\n");
}
return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
#第二回全国統一プログラミング王決定戦予選 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def dijkstra(s,graph):
    d = [inf]*n
    d[s] = 0
    h = [(0,s)]
    while h:
        c,v = heappop(h)
        if d[v] < c:
            continue
        for t,cost in graph[v]:
            if d[v] + cost < d[t]:
                d[t] = d[v] + cost
                heappush(h,(d[t],t))
    return d

n,m = LI()
lrc = [LI() for _ in range(m)]
edge = [[] for _ in range(n)]
for l,r,c in lrc:
    edge[l-1].append((r-1,c))
for i in range(n-1):
    edge[i+1].append((i,0))
d = dijkstra(0,edge)
if d[-1] == inf:
    print(-1)
else:
    print(d[-1])

Measured memory_bytes: 93148
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

s = input()
C = collections.Counter(s)
# print(C)
for si in ("a","b","c"):
    if C[si]!=1:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int
int dp[200005][2] = {};
void solve(std::string T) {
  int n = T.size();
  rep(i, n) {
    if (T[i] == '?') {
      T[i] = 'D';
    }
  }
  // int ans = 0;
  // rep(i, n) {
  //   if (i + 1 < n && T[i] == 'P' && T[i + 1] == 'D')
  //     ans++;
  //   if (T[i] == 'D')
  //     ans++;
  // }
  cout << T << endl;
}

signed main() {
  std::string T;
  std::cin >> T;
  solve(T);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
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; }
//template end



int main(){
    ll a,b,k; scanf("%lld%lld%lld",&a,&b,&k);
    if(a+b<=k) printf("0 0\n");
    else if(a<=k){
        b=a+b-k;
        printf("0 %lld\n",b);
    }
    else{
        a-=k; printf("%lld %lld\n",a,b);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N, K;
    cin >> N >> K;

    vec<ll> P(N);
    rep(i, N) cin >> P[i], --P[i];

    vec<ll> C(N);
    rep(i, N) cin >> C[i];

    ll ans = -1e18 - 9;
    rep(i, N) {
        ll now = i;
        ll smS = 0;
        vec<ll> t;
        while (1) {
            smS += C[now];
            t.push_back(smS);
            now = P[now];
            if (now == i) break;
        }
        int L = t.size();
        rep(j, L) {
            ll zan = K - (j + 1);
            if (zan < 0) break;
            ll tmp = t[j];
            ll e   = zan / L;
            ans    = max({ans, tmp, tmp + smS * e});
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3816
#include<stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=1;i<=n;i++){
        scanf("%d",&a[n-i]);
    }
    for(int i=0;i<n;i++){
        if(i==n-1){
            printf("%d\n",a[i]);
        }else{
        printf("%d ",a[i]);
        }}
    
    return 0;
}



Measured memory_bytes: 2132
n = int(input())
b = list(map(int, input().split()))
a = [0] * n

a[0] = b[0]
a[1] = b[0]
for i in range(1, n - 1):
    if b[i] < a[i]:
        a[i] = b[i]
    a[i +1] = b[i]
print(sum(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535
 
int main() 
{
    FAST;
    ll n,k;
    cin>>n>>k;
    n=n%k;
    cout<<min(n,k-n);
    return 0;
}

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

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 2e5+10;
                        
int a[maxn];

int main(void){
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int k;
    cin >> k;
    for(int i = 1; i <= k; i++){
        cout<<"ACL";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<vector>
#define N 8

using namespace std;

int checkA(const vector<string>, int, int);
int checkB(const vector<string>, int, int);
int checkC(const vector<string>, int, int);
int checkD(const vector<string>, int, int);
int checkE(const vector<string>, int, int);
int checkF(const vector<string>, int, int);
int checkG(const vector<string>, int, int);

int main(){
  int i, j, isFound;
  string s;
  vector<string> data;

  while(cin >> s){
    data.push_back(s);

    for(i=1; i<N; ++i){
      cin >> s;
      data.push_back(s);
    }

    for(i=0, isFound=0; i<N; ++i){
      for(j=0; j<N; ++j){
        if(data[i][j] == '1'){
	  isFound = 1;
          break;
        }
      }
      if(isFound == 1) break;
    }

    if(checkA(data, i, j) == 1) cout << "A" << endl;
    else if(checkB(data, i, j) == 1) cout << "B" << endl;
    else if(checkC(data, i, j) == 1) cout << "C" << endl;
    else if(checkD(data, i, j) == 1) cout << "D" << endl;
    else if(checkE(data, i, j) == 1) cout << "E" << endl;
    else if(checkF(data, i, j) == 1) cout << "F" << endl;
    else if(checkG(data, i, j) == 1) cout << "G" << endl;

    data.clear();
  }

  return 0;
}

int checkA(const vector<string> data, int i, int j){
  int n, m;
  n = i + 1;
  m = j + 1;
  if(n < N && m < N){
    if(data[i][m] == '1' && data[n][j] == '1' && data[n][m] == '1')
      return 1;
  }
  return 0;
}

int checkB(const vector<string> data, int i, int j){
  int n;
  n = i + 3;

  if(n < N){
    if(data[i+1][j] == '1' && data[i+2][j] == '1' && data[n][j] == '1')
      return 1;
  }
  return 0;
}

int checkC(const vector<string> data, int i, int j){
  int n, m;
  n = j + 3;

  if(n < N){
    if(data[i][j+1] == '1' && data[i][j+2] == '1' && data[i][n] == '1')
      return 1;
  }
  return 0;
}

int checkD(const vector<string> data, int i, int j){
  int n, m;
  n = i + 2;
  m = j - 1;

  if(n < N && m >= 0){
    if(data[i+1][m] == '1' && data[i+1][j] == '1' && data[n][m] == '1')
      return 1;
  }
  return 0;
}

int checkE(const vector<string> data, int i, int j){
  int n, m;
  n = i + 1;
  m = j + 2;

  if(n < N && m < N){
    if(data[i][j+1] == '1' && data[n][j+1] == '1' && data[n][m] == '1')
      return 1;
  }
  return 0;
}

int checkF(const vector<string> data, int i, int j){
  int n, m;
  n = i + 2;
  m = j + 1;

  if(n < N && m < N){
    if(data[i+1][j] == '1' && data[i+1][m] == '1' && data[n][m] == '1')
      return 1;
  }
  return 0;
}

int checkG(const vector<string> data, int i, int j){
  int k, n, m;
  k = j - 1;
  n = i + 1;
  m = j + 1;

  if(k >= 0 && n < N && m < N){
    if(data[i][m] == '1' && data[n][k] == '1' && data[n][j] == '1')
      return 1;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;cin>>N;
    int ans=0;
    for(int i=1;i<=N;i++){
        if(i<=9){
            ans++;
        }else if(100<=i && i<=999){
            ans++;
        }else if(10000<=i && i<=99999){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=400010,P=1e9+7;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
inline int ksm(int x,int y){
	int z=1;for(;y;y>>=1,x=1ll*x*x%P)
	if(y&1)z=1ll*z*x%P;return z;
}
#include<vector>
vector<int>h[N];
int n,fa[N],c[N],w[N],fac[N],inv[N],X,Y,ans,sz[N],id[N];
inline bool cmp(int i,int j){return w[i]<w[j];}
inline bool pmc(int i,int j){return fa[i]<fa[j];}
inline int get(int x){return fa[x]==x?x:fa[x]=get(fa[x]);}
void fuck(int x,int y){
	x=get(x);y=get(y);
	if(x==y)return;
	fa[x]=y;sz[y]+=sz[x];
}
	int i,mn,k;
int main(){
	//freopen("1.out","w",stdout);
	n=read();X=read();Y=read();
	for(i=1;i<=n;i++){
		c[i]=read();
		w[i]=read();
		h[c[i]].push_back(i);
		id[i]=i;fa[i]=i;sz[i]=1;
	}
	sort(id+1,id+n+1,cmp);
	mn=id[1];k=0;
	for(i=2;i<=n;i++){
		if(w[id[i]]+w[mn]<=Y&&c[id[i]]!=c[mn])fuck(id[i],mn);
		if(!k&&c[id[i]]!=c[mn])k=id[i];
		else{if(w[id[i]]+w[k]<=Y&&c[id[i]]!=c[k])fuck(id[i],mn);}
	}
	for(k=1;k<=n;k++){
		if(!h[k].size())continue;
		sort(h[k].begin(),h[k].end(),cmp);
		mn=h[k][0];
		for(i=h[k].size()-1;i;i--)
		if(w[h[k][i]]+w[mn]<=X)fuck(h[k][i],mn);
	}
	fac[0]=ans=1;
	for(i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%P;
	inv[n]=ksm(fac[n],P-2);
	for(i=n;i>=1;i--)inv[i-1]=1ll*inv[i]*i%P;
	for(i=1;i<=n;i++)if(get(i)==i)
	ans=1ll*ans*fac[sz[i]]%P;
	for(k=1;k<=n;k++){
		if(!h[k].size())continue;
		sort(h[k].begin(),h[k].end(),pmc);
		for(i=h[k].size()-1;i>=0;i=mn){
			for(mn=i;mn>=0&&fa[h[k][mn]]==fa[h[k][i]];mn--);
			ans=1ll*ans*inv[i-mn]%P;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 24192
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
using namespace std;
const int MAXN = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;
char G[210][210];
char C[210];
int depth[210];
char vis[210];
queue<int> q;
int maxi;

int main()
{
	int i, j;
	scanf("%d", &N);
	for (i = 0; i < N; ++i) {
		scanf("%s", &G[i]);
	}

	q.push(0);
	memset(C, -1, sizeof(C));
	C[0] = 0;
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		for (i = 0; i < N; ++i) {
			if (G[u][i] == '1') {
				if (C[i] == C[u]) {
					printf("-1");
					return 0;
				}
				if (C[i] != -1) continue;
				C[i] = !C[u];
				q.push(i);
			}
		}
	}
	
	for (i = 0; i < N; ++i) {
		memset(vis, 0, sizeof(vis));
		q.push(i);
		vis[i] = 1;
		depth[i] = 1;
		while (!q.empty()) {
			int u = q.front();
			q.pop();
			for (int v = 0; v < N; ++v) {
				if (G[u][v] == '1') {
					if (vis[v]) continue;
					depth[v] = depth[u] + 1;
					maxi = max(maxi, depth[v]);
					vis[v] = 1;
					q.push(v);
				}
			}
		}
	}
	printf("%d", maxi);
	return 0;

}

Measured memory_bytes: 256
lst = list(map(int,input().split()))
lst2 = list(map(lambda x: max(lst) - x, lst))
lst2.remove(0)
if lst2[0] % 2 == lst2[1] % 2:
    print(sum(lst2) // 2)
else:
    print((sum(lst2) + 3) // 2)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){

    long long N;
    long long T;

    cin >> N >> T;

    vector<long long>v(N);
    for(long long i = 0; i < N; i++){
        cin >> v[i];
    }

    long long ans = 0;
    for(long long i = 1; i < N; i++){
        if(v[i] - v[i-1] > T) {
            ans += T;
        }
        else{
            ans += v[i] - v[i-1];
        }
    }

    cout << ans + T << endl;


}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define fst first
#define scn second
int main(){
	while(true){
		int n,m,a;	cin>>n>>m>>a;
		if(n==0&&m==0&&a==0)	break;
		vector<pair<int,pair<int,int>>> ls;
		for(int i=0;i<m;i++){
			int h,p,q;	cin>>h>>p>>q;
			ls.push_back(make_pair(h,make_pair(p,q)));
		}
		sort(ls.begin(),ls.end());
		reverse(ls.begin(),ls.end());
		for(int i=0;i<m;i++){
			if(ls[i].scn.fst==a)	a=ls[i].scn.scn;
			else if(ls[i].scn.scn==a)	a=ls[i].scn.fst;
		}
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 3108
// Problem : E - Bomber
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)           (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)        cout << #x << " = " << x << endl
#define trace(x)        cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

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

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	int h,w,m; cin>>h>>w>>m;
	set<pii>st;
	mii row,col;
	fo(i,m){
		int x,y; cin>>x>>y;
		st.insert(mp(x,y));
		row[x]++;
		col[y]++;
	}
	int rowmax = 0, colmax = 0;
	vi x,y;
	for(pii p : row){
		rowmax = max(rowmax,p.ss);
	}
	for(pii p : row){
		if(p.ss == rowmax) x.pb(p.ff);
	}
	for(pii p : col){
		colmax = max(colmax,p.ss);
	}
	for(pii p : col){
		if(p.ss == colmax) y.pb(p.ff);
	}
	int ans;
	if(sz(x)*sz(y) > m) ans = rowmax + colmax;
	else{
		ans = rowmax + colmax - 1;
		for(auto i : x){
			for(auto j : y){
				if(st.count({i,j}) == 0) ans = rowmax + colmax;
			}
		}
	}
	cout<<ans;
}

 
int32_t main()
{
    babuBhaiya();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

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



signed main(){
    IOS;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
    	if (s[i] == '7') return cout << "Yes\n", 0;
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = INF;
  for (int k = 0; k <= max(x,y); ++k) {
    int tmp = 2*c*k;
    tmp += a*max(0,x-k);
    tmp += b*max(0,y-k);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

void solve(char a[105][105], int inp, int d, int y, int x){
    int i;
    for(i = 0; i < inp - 1; i++){
        a[y][x] = '#';
        if(d == 0){
            if(a[y - 2][x] == '#') break;
            y--;
        }else if(d == 1){
            if(a[y][x + 2] == '#') break;
            x++;
        }else if(d == 2){
            if(a[y + 2][x] == '#') break;
            y++;
        }else{
            if(a[y][x - 2] == '#') break;
            x--;
        }
    }
    if(i <= 1) return;
    solve(a, inp, (d + 1) % 4, y, x);

}

int main(){
    int n;
    char a[105][105];
    cin >> n;
    rep(i,n){
        if(i) cout << endl;
        rep(i,105) rep(j,105) a[i][j] = ' ';
        int inp;
        cin >> inp;
        solve(a, inp, 0, 104, 0);
        if(inp == 1) cout << '#' << endl;
        else if(inp == 2) cout << "##" << endl << "# " << endl;
        else{
            for(int i = 104 - inp + 1; i <= 104; i++){
                rep(j,inp){
                    cout << a[i][j];
                }
                cout << endl;
            }
        }
    }
}

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

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

  int N = a.length();

  int counta = 0;
  int countb = 0;

  for(int i=0;i<N;++i){
    if(a[i]=='0') ++counta;
    else ++countb; 
  }

  cout << 2*min(counta,countb) << endl;

}

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

int main(){
    int sum = 0;
    int n,m;
    cin >> n >> m;
    while (m--){
        int k;
        cin >> k;
        sum += k;
    }
    if (n-sum >= 0){
        cout << n-sum;
    }
    else{
        cout << -1;
    }
}

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

#define loop(s, e, i) for (int i=s; i<e; ++i)
#define print(s) cout << s << endl;
using namespace std;
using ll = long long;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

struct Data {
  int r, l, k;
};

int main() {
  ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
  string S;
  cin >> S;
  int N = S.length();
  vector<Data> A(N);

  loop(0, N, i) {
    if (S[i] == 'R') {
      A[i].k = 0;
    } else {
      A[i].k = 1;
    }
  }
  A[0].r = 0;
  for (int i=0; i<N; i++) {
    if (S[i] == 'R') {
      A[i].r = i;
    } else {
      A[i].r = A[i-1].r;
    }
  }
  A[N-1].l = N-1;
  for (int i=N-2; i>=0; i--) {
    if (S[i] == 'L') {
      A[i].l = i;
    } else {
      A[i].l = A[i+1].l;
    }
  }
  vector<int> COUNT(N);
  loop(0, N, i) {
    if (A[i].k == 0) {
      int d = A[i].l - i;
      if (d%2 == 0) {
        COUNT[A[i].l]++;
      } else {
        COUNT[A[i].l-1]++;
      }
    } else {
      int d = i - A[i].r;
      if (d%2 == 0) {
        COUNT[A[i].r]++;
      } else {
        COUNT[A[i].r+1]++;
      }
    }
  }
  loop(0, N, i) {
    if (i == N-1) {
      cout << COUNT[i] << endl;
    } else {
      cout << COUNT[i] << " ";
    }
  }
}

Measured memory_bytes: 5028
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    vector<ll> t(2);
    vector<pair<ll,ll>> ab(2);
    rep(i, 2) cin >> t[i];
    rep(i, 2) cin >> ab[i].first >> ab[i].second;

    sort(all(ab), greater<pair<ll,ll>>());

    ll diff1 = (ab[0].first - ab[1].first) * t[0];
    ll diff2 = (ab[0].second - ab[1].second) * t[1];
    ll diff3 = (ab[0].second * t[1] + diff1) - ab[1].second * t[1];
    if(diff3 == 0){
        cout << "infinity" << endl;
        return 0;
    }

    //cout << diff1 << " " << diff2 << "  " << diff3 << endl;

    if(diff3 > 0){
        cout << 0 << endl;
        return 0;
    }

    if(diff1 % diff3 == 0){
        cout << abs(diff1 / diff3) * 2 << endl;
    } else {
        cout << abs(diff1 / diff3) * 2 + 1 << endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define in_arr(name,size) for(int i = 0;i<size;i++)\
cin >> name[i];
#define QUICK ios_base::sync_with_stdio(0);cout << fixed;

string upper(string);
string lower(string);
bool isalup(string);
bool isalow(string);
/*
class node{
public:
    int val;
    node* next;
    node(int a){
        next = NULL;
        val = a;
    }
    ~node(){
        cout << "One node is removed\n";
    }
};

class linklist{
    public:
    node*head = NULL;
    node* tail;
    void add(int a){
        node*temp = new node(a);
        temp->next = head;
        head = temp;
        if(size()==1)
            tail = head;
    }
   bool isempty(){
        return head == NULL;
    }
    void remove_front(){
        node* temp = head;
        head = head->next;
        delete temp;
    }
    void remove_val(int a){
        if(!detect(a)){
            cout << "Element not founded\n";
            return;
        }
        cout << "akan ada node yang akan dihapus\n";
        node* temp = head;
        node* dummy = new node(0);
        dummy->next = head;
        node*temp_2 = dummy;

        while(temp&&temp_2){
            if(temp->val==a)
            {
                node* temp_3 = temp;
                temp_2->next = temp->next;
                if(temp->next==NULL)
                    break;
                temp = temp->next->next;
                delete temp_3;
                continue;
            }
            temp_2 = temp_2->next;
            temp = temp->next;
        }

        delete dummy;
    }
    ~linklist(){
        while(!isempty()){
            remove_front();
        }
    }
    bool detect(int a){
        node* temp = head;
        while(temp!=NULL){
            if(temp->val==a)
                return true;
            temp = temp->next;
        }
        return false;
    }
    int size(){
        int a = 0;
        node*temp = head;
        while(temp){
            a++;
            temp = temp->next;
        }
        return a;
    }

};*/

int main(){
    
    int a,ans = 0;
    cin >> a;
    vector<int>wow(a);
    in_arr(wow,a)
    
    for(int i = 0;i<a;i += 2)
        if(wow[i]%2==1)
        ans++;
    cout << ans;
    /* cout << "TES\n";
    linklist one;
    cout << "TES\n";
    one.add(20);
    cout << "TES\n";
    one.add(50);
    cout << "TES\n";
    one.add(100);
    cout << "TES\n";
    one.add(20);
    cout << "TES\n";
    one.remove_val(20);
    cout << "TES\n";
    cout << "Size linked list :" << one.size() << endl;*/

    return 0;
}









string upper(string a){
    for(char& c:a){
        if(islower(c))
            c -= 32;
       }
    return a;
}
    string lower(string a){
        for(char& c : a){
            if(isupper(c))
                c += 32;
        }
        return a;
    }
    bool isalup(string a){
        for(char& c: a){
            if(islower(c))
                return false;
        }
        return true;
    }
    bool isalow(string a){
        for(char& c:a){
            if(isupper(c))
                return false;
        }
       return true;
    }


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	int N;
	cin >> N;
	if(N == 0 || N == 2){
		cout << 1 << endl;
	}else if(N == 1){
		cout << 2 << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,a,cnt2=0,cnt4=0;
    cin>>n;
    rep(i,n){
        cin>>a;
        if(a%4==0) cnt4++;
        else if(a%2==0) cnt2++;
    }
    cout<<(2*cnt4+max(cnt2-1,(ll)0)>=n-1?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))
r = [0]*N
r[0] = (p[0] + 1) / 2
for i in range(1, N):
    r[i] = r[i-1] + (p[i] + 1) / 2
ans = r[K-1]
for i in range(K, N):
    ans = max(ans, r[i] - r[i - K])
print(ans)

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e6 + 7;
const int N = 2e5 + 7;
const int M = 20;
const ll mod = 998244353;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

void solve1()
{
    int n;
    cin >> n;
    vector < ll > v(n);
    vector < ll > kol(n , 0);
    for( int i = 0; i < n; i++ ){
        cin >> v[i];
        v[i] -= 1;
        kol[v[i]] += 1;
    }
    ll ans = 0;
    for( int i = 0; i < n; i++ ){
        ans += kol[i] * (kol[i] - 1) / 2;
    }
    for( int j = 0; j < n; j++ ){
        int i = v[j];
        ans -= kol[i] * (kol[i] - 1) / 2;
        kol[i] -= 1;
        ans += kol[i] * (kol[i] - 1) / 2;
        cout << ans << "\n";
        ans -= kol[i] * (kol[i] - 1) / 2;
        kol[i] += 1;
        ans += kol[i] * (kol[i] - 1) / 2;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 5760
#include<stdio.h>
int main()
{
  int a,b,i,j;
  while(1)
	   {
  scanf("%d%d",&a,&b);
  if(a==0&&b==0){break;}

  for(i=1;i<=a;i++)
    {
      for(j=1;j<=b;j++)
	{
	  if(i>1&&i<a&&j<b&&j>1)printf(".");
	  else printf("#");
	}
      printf("\n");
    }
  printf("\n");
    
	   }
  return 0;
}


Measured memory_bytes: 2044
#include<cstdio>
#include<algorithm>
#define MAXN 100006
using namespace std;
int n;
struct node
{
	int t,x,y;
}q[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&q[i].t,&q[i].x,&q[i].y);
	int ok=1;
	for(int i=1;i<=n;i++)
	{
		int dt=q[i].t-q[i-1].t;
		int dx=abs(q[i].x-q[i-1].x);
		int dy=abs(q[i].y-q[i-1].y);
		if(dt<dx+dy||(dt-dx-dy)%2==1)
		{
			ok=0;
			break;
		}
	}
	if(ok) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi c(n-1), s(n-1), f(n-1);
  rep(i, n-1) cin >> c[i] >> s[i] >> f[i];

  vi t(n);
  rep(i, n){
    t[i] = (i == n-1 ? 0 : s[i]);
    for (int j = i; j < n-1; j++) {
      if(t[i] < s[j]) t[i] = s[j];
      else{
        int r = (t[i]-s[j])%f[j];
        if(r != 0) t[i] += f[j] - r;
      }
      t[i] += c[j];
    }
  }
  rep(i, n) std::cout << t[i] << '\n';
}


Measured memory_bytes: 256
n = int(input())
nl = map(int, (i for i in range(1, n + 1, 2)))
ans = 0


def eight(num):
    i = 1
    cnt = 0
    while i <= num:
        if num % i == 0:
            cnt += 1
        i += 1
    if cnt == 8:
        return 1
    else:
        return 0


for i in nl:
    ans += eight(i)

print(ans)


Measured memory_bytes: 3060
import sys
import math
import copy
import queue
input = sys.stdin.readline
def LI(): return [int(x) for x in input().split()]

l =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print (l[k-1])


Measured memory_bytes: 40556
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define MOD 1000000009
using namespace std;
typedef long long ll;
int main()
{
  string str;
  cin >> str;
  if(str[0] == str[1]){
    if(str[0] != str[2] && str[2]  == str[3]) {cout << "Yes" << endl; return 0;}
  }
  if(str[0] == str[2]){
    if(str[0] != str[1]&&str[1]  == str[3]) {cout << "Yes" << endl; return 0;}
  }
  if(str[0] == str[3]){
    if(str[0] != str[1]&&str[1]  == str[2]) {cout << "Yes" << endl; return 0;}
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# scipy version

import sys
from collections import deque
from array import array

import numpy

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import connected_components

def input():
    return sys.stdin.readline().rstrip('\n')

##### main

N,M = list(map(int, input().split()))

#C = [[0]*N for _ in range(N)]
#
#for i in range(M):
#    a,b,c = list(map(int, input().split()))
#    C[a-1][b-1] = c

R = numpy.full(M, 0, dtype=numpy.int32)
C = numpy.full(M, 0, dtype=numpy.int32)
V = numpy.full(M, 0, dtype=numpy.int32)

for i in range(M):
    r,c,v = list(map(int, input().split()))
    R[i] = r-1
    C[i] = c-1
    V[i] = v

matrix = csr_matrix((V,(R,C)), shape=(N,N))

n = connected_components(matrix, directed=False, return_labels=False)

print(n)


Measured memory_bytes: 18880
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    int p, q;
    
    while(cin >> p >> q && (p || q))
    {
        vector<pint> num;
        set<int> dic;
        
        int bFirst = 0;
        do
        {
            if(bFirst++) dic.insert(p);
                        
            p = p % q * 10;
            
            num.push_back(mp(p, p / q));          
        }
        while (dic.find(p) == dic.end() && p != 0);
        
        
        rep(i, num.size() - 1)
            cout << num[i].second << (i == num.size() - 2 ? "\n" : "");
        
        bool r = false;
        for(int i = 0; p != 0 && i < num.size() - 1; i++)
        {
            r |= num[i].first == p;
            cout << (r ? "^" : " ") << (i == num.size() - 2 ? "\n" : "");
        }
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const int M = 55;

int a[M][5];
int b[M][5];

int jude(int x, int y, int m){
	int x1,y1;
	int now = 1;
	int v = abs(x - b[0][0]) + abs(y - b[0][1]);
	for(int i = 1; i < m; i++){
		x1 = abs(x - b[i][0]);
		y1 = abs(y - b[i][1]);
		if((x1 + y1) < v){
			now = i+1;
			v = x1 + y1;
		}
	}
	return now;
}

int main(){
	int n,m;
	int ans;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 2; j++) scanf("%d",&a[i][j]);
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < 2; j++) scanf("%d",&b[i][j]);
	}

	for(int i = 0; i < n; i++){
		ans = jude(a[i][0] , a[i][1] , m);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
city = []
for i in range(m):
    p, y = map(int, input().split())
    city.append([p, y, i])

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

res = [''] * m
cnt = 1
for i in range(m):
    res[city[i][2]] = str(city[i][0]).zfill(6) + str(cnt).zfill(6)
    if i + 1 < m and city[i][0] == city[i+1][0]:
        cnt += 1
    else:
        cnt = 1


for num in res:
    print(num)

Measured memory_bytes: 98220
N = int(input())
info = [list(map(int,input().split())) for i in range(N-1)]
for i in range(N-1):
    t = 0
    for c,s,f in info[i:]:
        # 開通式の待ち時間
        if t <= s:
            wait = s - t
            t += wait
        else:
            pass_time = t - s
            if pass_time % f == 0:
                wait = 0
            else:
                pass_time %= f
                wait = f - pass_time
            t += wait
        # 通行時間
        t += c
    print(t)
print(0)

Measured memory_bytes: 3316
<?php

$list=array_fill(0,1001,0);
for($i=1;$i<=1000;$i++){
    $list[$i]=$list[$i-1]+$i;
}

while(1){
    fscanf(STDIN,"%d",$l);
    if($l==0)
        break;
    $sum=0;
    for($i=ceil($l/2);$i>=1;$i--){
        for($j=0;$j<$i;$j++){
            if($list[$i]-$list[$j]==$l){
                $sum++;
            }
        }
    }
    if($l==1)
        echo "0\n";
    else
        echo $sum."\n";
}
?>

Measured memory_bytes: 6740
#include <bits/stdc++.h>
using namespace std;
long long n , ans=10000 , sum ,temp;
signed main(){
  cin>>n;
  for(long long i=1;i*i<=n;i++){
    if(n%i == 0){
      if(i > n/i){
        temp=i;
      } else {
        temp = n/i;
      }
      sum=0;
      while(temp>0){
        temp/=10;
        sum++;
      }
      if(ans > sum){
        ans=sum;
      }
    }
  }
  
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]  # 親のノード番号
        self.rank = [0]*(n+1)
        self.X = [0]+[1]*n
    def find(self,x):  # xの根のノード番号
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self,x,y):  # x,yが同じグループか否か
        return self.find(x) == self.find(y)
    def unite(self,x,y):  # x,yの属するグループの併合
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            x,y = y,x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x
        self.X[x] = self.X[x]+self.X[y]


N,M = MI()
UF = UnionFind(N)
AB = [tuple(MI()) for _ in range(M)]
AB.reverse()

ans = N*(N-1)//2
ANS = []
for i in range(M):
    ANS.append(ans)
    a,b = AB[i]
    if UF.same_check(a,b):
        continue
    else:
        ans -= UF.X[UF.find(a)]*UF.X[UF.find(b)]
        UF.unite(a,b)

ANS.reverse()
print(*ANS,sep='\n')


Measured memory_bytes: 98984
#include "bits/stdc++.h"
using namespace std ;


int main(){
	int N ;
	cin >> N ;
	int a[51] ;
	double sum = 0.0 ;
	cin >> a[0] ;
	for( int i = 1 ; i < N ; i++ ){
		cin >> a[i] ;
	}
	sort(a,a+N);
	sum = a[0];
	for( int i = 1 ; i < N ; i++ ){
		sum += a[i];
		sum /= 2.0 ;
	}

	printf("%lf\n",sum);


	return 0 ;
}

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

int main(){
	int A,B,C,X,a,b,c,S,ans=0;
	cin>>A>>B>>C>>X;//Xは50の倍数
	
	for(int i=0;i<=A;i++){
		a=i;
		for(int j=0;j<=B;j++){
			b=j;
			S=500*a+100*b;
			c=(X-S)/50;
			if(c>=0&&c<=C)
				ans++;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<map>
#include<set> 
using namespace std;

struct node{
	int x,y;
}a[105],b[105];

int cmp(node p,node q){
	if(p.x==q.x){
		return p.y<q.y;
	}else return p.x<q.x;
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
	}	
	for(int i=0;i<n;i++){
		scanf("%d%d",&b[i].x,&b[i].y);
	}
	sort(b,b+n,cmp);
	int ans=0,c[105];
	memset(c,0,sizeof(c));
	for(int i=0;i<n;i++){
		int maxm=-1,num=-1;
		for(int j=0;j<n;j++){
			if(!c[j]&&a[j].x<b[i].x&&a[j].y<b[i].y&&a[j].y>maxm){
				maxm=a[j].y;
				num=j;
			}
		}
		if(num!=-1){
			c[num]=1;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};

int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    int n;
    double d;
     cin>>n>>d;
     int cnt=0;
     while(n--)
     {
        ll x,y;
         cin>>x>>y;
         if(x<0) x=-x;
         if(y<0) y=-y;
        ll ans=x*x+y*y;
         ans=sqrt(ans);
         if(ans*ans==x*x+y*y)
         {
             if(ans<=d) ++cnt;
         }
         else
         {
             if(ans<d) ++cnt;
         }
     }
     cout<<cnt<<endl;

}




Measured memory_bytes: 3704
#include <cstdio>
#include <bitset>
#include <cstring>
#define rep(a,b,c) for(int a=b;a<=c;a++)
using std::bitset;
bitset<4000001> s;
int n,a[2001],S,sum,ans;
int main() {
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]),sum+=a[i]; S=sum; sum/=2;
	s[0]=1;
	rep(i,1,n) s|=(s<<a[i]);
	rep(i,0,sum) if(s.test(i)) ans=i;
	printf("%d",S-ans);
}

Measured memory_bytes: 4688
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();
		String w ="fjyfyucu7t6r5dc";
		s = s.replaceAll("apple", w);
		s = s.replaceAll("peach", "apple");
		s = s.replaceAll(w, "peach");
		System.out.println(s);
	}
}


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

int main() {
    string o, e;
    cin >> o >> e;
    string ans;
    rep(i,min(o.size(), e.size())) {
        ans += o[i];
        ans += e[i];
    }
    if (o.size() > e.size()) {
        ans += o.back();
    }
    cout << ans << endl;
}

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

int main() {
	string s, t;

	cin >> s;
	cin >> t;

	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			count++;
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3912
n=int(input())
p=list(map(float,input().split()))
dp=[[0]*(n+1) for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
  dp[i+1][0]=dp[i][0]*(1-p[i])
  for j in range(i+1):
    dp[i+1][j+1]=dp[i][j]*p[i]+dp[i][j+1]*(1-p[i])
print(sum([dp[n][i] for i in range((n+1)//2,n+1)]))

Measured memory_bytes: 204596
s = input()
k = int(input())
alphabets = sorted(set(list(s)))

# 答えとなるsubstringは必ずK文字以下
res = set()
# 頭文字(alphabetsの添字)
prefix = 0
while len(res)<k:
    # 頭文字のみの場合
    res.add(alphabets[prefix])
    for i in range(len(s)):
        #print(i,res)
        if s[i]==alphabets[prefix]:
            # 2文字以上の部分文字列をresに追加
            length = 2
            while length<=k:
                if i+length>len(s):
                    break
                res.add(s[i:i+length])
                length += 1
    prefix += 1

print(sorted(res)[k-1])


Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
char mp[1005][1005];
int vis[1005][1005];
int h,w,s1,s2,e1,e2;
struct node{
    int x,y;
}tmp;
bool check(int x,int y)
{
    if(x<0||x>=h||y<0||y>=w)
        return false;
    if(mp[x][y]=='#')
        return false;
    return true;
}
bool chmin(int &a,int b)
{
    if(a>b)
    {
        a=b;
        return true;
    }
    return false;
}
void bfs()
{
    deque<node>que;
    mm(vis,0x3f);
    tmp={s1,s2};
    vis[s1][s2]=0;
    que.push_back(tmp);
    while(!que.empty())
    {
        tmp=que.front();
        que.pop_front();
        for(int dx=-1;dx<=1;++dx)
            for(int dy=-1;dy<=1;++dy)
            {
                if(dx!=0&&dy!=0)
                    continue;
                int nx=tmp.x+dx;
                int ny=tmp.y+dy;
                if(check(nx,ny))
                {
                    if(chmin(vis[nx][ny],vis[tmp.x][tmp.y]))
                        que.push_front({nx,ny});
                }
            }
        for(int dx=-2;dx<=2;++dx)
            for(int dy=-2;dy<=2;++dy)
            {
                int nx=tmp.x+dx;
                int ny=tmp.y+dy;
                if(check(nx,ny))
                {
                    if(chmin(vis[nx][ny],vis[tmp.x][tmp.y]+1))
                        que.push_back({nx,ny});
                }
            }
    }
}
int main(void)
{
    sync;
    cin>>h>>w>>s1>>s2>>e1>>e2;
    s1-=1,s2-=1;
    e1-=1,e2-=1;
    for(int i=0;i<h;++i)
        for(int j=0;j<w;++j)
            cin>>mp[i][j];
    bfs();
    if(vis[e1][e2]==0x3f3f3f3f)
        cout<<-1<<endl;
    else
        cout<<vis[e1][e2]<<endl;
    return 0;
}

Measured memory_bytes: 8096