akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> p;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1000000000000000000LL;//1e18
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}

struct edge{
    ll to;
    ll cost;
};
struct graph{
    ll v;
    vec<vec<edge>> g;
    vec<ll> d;
    graph(ll n) : v(n),g(n),d(n,INF) {}
    void add(ll a,ll b,ll c){
        edge e;
        e.to=b,e.cost=c;
        g[a].emplace_back(e);
    }

    void dijkstra(ll s){
        d[s]=0;
        priority_queue<p,vec<p>,greater<p>> que;
        que.push(p(0,s));//距離,位置(距離でsortされるように)
        while(!que.empty()){
            p now=que.top();que.pop();
            if(now.first>d[now.second])continue;
            for(edge ne : g[now.second]){
                if(ne.cost+now.first<d[ne.to]){
                    d[ne.to]=ne.cost+now.first;
                    que.push(p(d[ne.to],ne.to));
                }
            }
        }
    }
};


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,m,r;cin >> n >> m >> r;
    graph g(n);
    rep(i,m){
        ll s,t,d;cin >> s >> t >> d;
        g.add(s,t,d);
    }
    g.dijkstra(r);
    rep(i,n){
        if(g.d[i]<INF)cout << g.d[i] << endl;

        else cout << "INF" << endl;
    }
}


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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << "\n"
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << "\n"
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <limits>

using namespace std;

int
main(int argc, char** argv) {
    int32_t n; cin >> n;
    vector<int32_t> A(n);
    int32_t minval = numeric_limits<int32_t>::max();
    int64_t diff   = numeric_limits<int64_t>::lowest();
    for(size_t i = 0; i < n; ++i) {
        cin >> A[i];
        if (i == 0) {
            minval = A[i];
        } else if (diff < (A[i] - minval)) {
            diff = A[i] - minval;
        }
        if (A[i] < minval) { minval = A[i]; }
    }
    cout << diff << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define PI 3.14159265358979323846  
typedef pair<int, int> P;

int main() {
	int n,ans;
	cin >> n;
	ans = 1000 - n % 1000;
	if (ans == 1000) {
		ans = 0;
	}
	cout <<ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
using namespace std;

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

	if (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
/*input
6
b
a
abc
c
d
ab
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

const ll P = 31;
const ll MX = 1000005;

ll pwr[MX];
map<pair<ll, ll>, vector<ll> > f;
vector<string> v;

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	ll n; cin >> n;
	pwr[0] = 1;
	for(ll i = 1; i < MX; i++) {
		pwr[i] = (P * pwr[i - 1]) % MOD;
	}
	ll ans = 0;
	for(ll i = 0; i < n; i++) {
		string s; cin >> s;
		v.push_back(s);
	}
	sort(v.begin(), v.end(), [&](string &a, string &b) -> bool {
		return a.size() > b.size();
	});
	for(auto s: v) {
		vector<ll> freq(26);
		for(auto c: s) {
			freq[c - 'a']++;
		}
		ll hash = 0;
		for(ll j = s.size() - 1; j >= 0; j--) {
			if(!f.count({hash, s.size() - 1 - j})) {
				f[{hash, s.size() - 1 - j}] = vector<ll>(26);
			}
			auto now = &f[{hash, s.size() - 1 - j}];
			for(ll k = 0; k < 26; k++) {
				if(freq[k]) ((*now)[k])++;
			}
			if(j) {
				freq[s[j] - 'a']--;
				hash = (hash + (ll)(s[j]) * (pwr[s.size() - 1 - j])) % MOD;
			}
		}
		auto val = f[{hash, s.size() - 1}];
		ll match = s[0] - 'a';
		ans += (val[match] - 1);
	}
	cout << ans << endl;
	return 0;
}




















Measured memory_bytes: 308512
def main():
    N, M = map(int, input().split())
    S = []
    for _ in range(M):
        k, *s = map(int, input().split())
        S.append(s)
    P = list(map(int, input().split()))
    ans = 0
    for i in range(1<<N):
        on = []
        for j in range(N):
            if (i >> j) & 1:
                on.append(j+1)
        flag = True
        for m in range(M):
            cnt = 0
            for o in on:
                if o in S[m]:
                    cnt += 1
            if cnt % 2 != P[m]:
                flag = False
                break
            if not flag:
                break
        
        if flag:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 42560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const int MAX_N = 1e5+3;
int A[MAX_N], B[MAX_N];
int N;

void solve()
{
	ll s1 = accumulate(A, A+N, 0LL), s2 = accumulate(B, B+N, 0LL);
	int ans = 0;
	if(s1 < s2) ans = -1;
	else{
		vector<int> diff;
		for(int i=0;i<N;++i) if(A[i]>B[i]) diff.pb(A[i]-B[i]);
		sort(diff.begin(), diff.end(), greater<int>());
		int idx = -1;
		for(int i=0;i<N;++i){ 
			if(A[i]<B[i]){
				int need = B[i]-A[i];
				while(need > 0){
					if(idx < 0){
						ans++;
						idx++;
					}else if(diff[idx] < need){
						need -= diff[idx], ans++, idx++;
					}else{
						diff[idx]-=need;
						break;
					}
				}
				ans++;
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	for(int i=0;i<N;++i)cin >> A[i];
	for(int i=0;i<N;++i)cin >> B[i];
	solve();
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include <math.h>
#include <stdlib.h>

int main (){
  int n,t[1000001],x[1000001],y[1000001],a,b,c,i,j,k,tr;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d %d",&t[i],&x[i],&y[i]);
  }
  t[0]=0;
  x[0]=0;
  y[0]=0;
  for(i=1;i<=n;i++){
    if((abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))<=(t[i]-t[i-1]) && ((abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))-(t[i]-t[i-1]))%2==0){
      a=0;
    } else {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 6528
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int n, a;
    cin >> n >> a;
    if (n%500 <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>


using namespace std;

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i=0; i<n; i++){
        string a;
        cin >> a;
        mp[a]++;
    }
    int max = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(max < itr->second) max=itr->second;
    }

    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second == max){
            cout << itr->first << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 25216
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;

int main()
{
    int n;
    cin >> n;
    bool ans = false;
    rep(i, 3) {
        if (n % 10 == 7) ans = true;
        n = n / 10;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
	string S;
	int K;
	cin >> S >> K;
	int N = S.size();
	vector<vector<ll>> dp_less(N+1, vector<ll>(K+1, 0));
	vector<vector<ll>> dp_eq(N+1, vector<ll>(K+1, 0));

	vector<int> A(N+1, 0);
	for(int i=1;i<=N;i++) A[i] = S[i-1] - '0';

	// 初期化
	dp_less[1][1] = A[1] - 1;
	dp_less[1][0] = 1;
	dp_eq[1][1] = 1;

	for(int i=2;i<=N;i++) {
		for(int j=1;j<=K;j++) {
			dp_less[i][0] = 1;
			// dp_eqからdp_eqに
			if(A[i] == 0) dp_eq[i][j] = dp_eq[i-1][j];
			else dp_eq[i][j] = dp_eq[i-1][j-1];
			// dp_lessからdp_lessに
			dp_less[i][j] += 9 * dp_less[i-1][j-1] + dp_less[i-1][j];
			// dp_eqからdp_lessに
			if(A[i] > 0) dp_less[i][j] += dp_eq[i-1][j] + (A[i] - 1) * dp_eq[i-1][j-1];
		}
	}

	cout << dp_less[N][K] + dp_eq[N][K] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<algorithm>

using namespace std;

long long c[10];

const long long INF=2e18;

map<long long,long long> dp;

long long dfs(long long x)
{
	if(!x)return 0;
	if(dp.count(x))return dp[x];
	long long tmp[6]={x/2,x/2+1,x/3,x/3+1,x/5,x/5+1},t[6]={2,2,3,3,5,5};
	long long ans=INF;for(int i=0;i<6;i++)if(tmp[i]<x)ans=min(ans,dfs(tmp[i])+(long long)min((long double)abs(tmp[i]-x)*c[0],abs(tmp[i]*t[i]-x)*(long double)c[0]+c[t[i]]));
	return dp[x]=ans;
}

int main()
{
	int T=0;scanf("%d",&T);
	while(T--)
	{
		long long x=0;scanf("%lld%lld%lld%lld%lld",&x,&c[2],&c[3],&c[5],&c[0]);
		printf("%lld\n",dfs(x));
		dp.clear();
	}
}

Measured memory_bytes: 4456
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

p.sort()
q.sort()
r.sort(reverse=True)
del p[:a-x]
del q[:b-y]

s=p+q
s.sort()
if s[0]<r[0]:
    s[0]=r[0]
    for i in range(1,c):
        if s[i]>=r[i]:
            break
        else:
            s[i]=r[i]

print(sum(s))

Measured memory_bytes: 22720
n=int(raw_input())
a=map(int,(raw_input().split()))
b=map(int,(raw_input().split()))

r=0
k=0
for i in range(n):
    if b[i]+k > a[i]:
        r+=a[i]
        if k > a[i]:
            k=b[i]
        else:
            k=b[i]+k-a[i]
    else:
        r+=b[i]+k
        k=0

r+=min(a[i+1],k)

print r


Measured memory_bytes: 14520
#include <iostream>
using namespace std;
int main()
{
  int len,c=0;
  string str,str1;
  getline(cin,str);
  getline(cin,str1);
  len=str.length();
  for(int i=0;i<len;i++)
  {
    if(str[i]!=str1[i])
    {
    	c++;
    }
  }
  cout<<c;
}


Measured memory_bytes: 3852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		boolean bb = true;
		while (bb) {
			int i = c - b;
			if (i <= 0) {
				System.out.println("Yes");
				break;
			} else {
				c = i;
			}
			int ii = a - d;
			if (ii <= 0) {
				System.out.println("No");
				break;
			} else {
				a = ii;
			}
		}

		sc.close();
	}
}

Measured memory_bytes: 27088
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p, std::vector<long long> q, std::vector<long long> r){
    sort(all(p),greater<>());
    sort(all(q),greater<>());
    sort(all(r),greater<>());

    vl cand1;
    rep(i,X)cand1.push_back(p[i]);
    rep(i,Y)cand1.push_back(q[i]);
    rep(i,C)cand1.push_back(r[i]);

    sort(all(cand1),greater<>());
    ll sum=0;
    rep(i,X+Y)sum+=cand1[i];
    cout<<sum<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> p(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> q(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&q[i]);
    }
    std::vector<long long> r(C);
    for(int i = 0 ; i < C ; i++){
        scanf("%lld",&r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
}


Measured memory_bytes: 7920
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  string s; cin >> s;
  ll gc=0, pc=0;
  ll ans = 0;
  REP(i, s.size()) {
    if (s[i] == 'g') {
      if (pc < gc) {
        pc++; ans++;
      } else {
        gc++;
      }
    } else {
      if (pc < gc) {
        pc++;
      } else {
        gc++; ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
hs= input().split()
h = int(hs[0])
s = int(hs[1])
my_list = input().split()
total = 0
for i in range(len(my_list)):
  my_list[i] = int(my_list[i])
my_list.sort(reverse = True)
for j in range(s, len(my_list)):
  total = total + my_list[j]
print(total)

Measured memory_bytes: 20016
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
int l[N];
signed main(){
  fast;
 
int n , x , ans = -1;
cin>>n>>x;
for(int i=0;i<n;i++) cin>>l[i];
for(int i=1;i<n ; i++)  l[i]+=l[i-1];
for(int i=0;i<n;i++) if(l[i]>x){
	ans=i+1;
	break;
}
if(ans==-1) ans = n+1;
cout<<ans<<endl;


}
  


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;   cin >> s;
    bool p = (s[0] == '7');
    bool q = (s[1] == '7');
    bool r = (s[2] == '7');

    if (p || q || r)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 2007;
const int ADD = 500107;

int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
bool b[4];

int id(char c)
{
    if (c == 'N') return 3;
    if (c == 'S') return 2;
    if (c == 'E') return 1;
    if (c == 'W') return 0;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	
	string s;
	cin >> s;
	
	int x = 0, y = 0;
	FOR (i,0,SZ(s))
	{
	    int d = id(s[i]);
	    x += dx[d];
	    y += dy[d];
	    b[d] = 1;
	}
	
	bool ok = 1;
	if (x < 0 && b[1] == 0) ok = 0;
	if (x > 0 && b[0] == 0) ok = 0;
	if (y < 0 && b[3] == 0) ok = 0;
	if (y > 0 && b[2] == 0) ok = 0;
	
	cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int max(int a, int b) {
	int c;
	if (a < b) {
		int temp = a;
		a = b;
		b = temp;
	}
	while (1) {
		c = a % b;
		if (c == 0) {
			return b;
		}
		a = b;
		b = c;
	}
}

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", max(a, b));
	return 0;
}


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

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<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;



int main(){
  string s;
  cin >> s;
  ll ans=0;
  ans=s.size()*(s.size()-1)/2;
  sort(s.begin(),s.end());
  vector<ll> v;
  ll cnt=1;
  FOR(i,s.size()-1){
    if(s[i]==s[i+1]){
      cnt++;
    }else{
      v.push_back(cnt);
      cnt=1;
    }
  }
  v.push_back(cnt);
  ll sum=0;
  FOR(i,v.size()){
    sum+=v[i]*(v[i]-1)/2;
  }
  sum--;

  cout << ans-sum << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
  
namespace ALDS1_3
{
    class Program
    {
        public class Process
        {
            public readonly string n;
            public readonly int t;
            public Process(string n, int t)
            {
                this.n = n;
                this.t = t;
            }
        }
  
        static void Main()
        {
            var s = Console.ReadLine().Split();
            var a = int.Parse(s[1]);
            var b = new Queue<Process>();
            string w;
 
            while ((w = Console.ReadLine()) != null)
            {
                var c = w.Split();
                var d = c[0]; var e = int.Parse(c[1]);
                b.Enqueue(new Process(d, e));
            }
  
            var f = 0;
  
            while (b.Count > 0)
            {
               var g = b.Dequeue();
               var k = g.n;
               var v = g.t;
               f += v < a ? v : a;
               v -= a;
               if (v <= 0)
                   Console.WriteLine("{0} {1}", k, f);
               else
                   b.Enqueue(new Process(k, v));
            }
        }
    }
}

Measured memory_bytes: 16944
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N >= 0 && N <= 1000){
            System.out.print(1000 - N);
        }else if(N > 1000 && N <= 2000){
            System.out.print(2000 - N);
        }else if(N > 2000 && N <= 3000){
            System.out.print(3000 - N);
        }else if(N > 3000 && N <= 4000){
            System.out.print(4000 - N);
        }else if(N > 4000 && N <= 5000){
            System.out.print(5000 - N);
        }else if(N > 5000 && N <= 6000){
            System.out.print(6000 - N);
        }else if(N > 6000 && N <= 7000){
            System.out.print(7000 - N);
        }else if(N > 7000 && N <= 8000){
            System.out.print(8000 - N);
        }else if(N > 8000 && N <= 9000){
            System.out.print(9000 - N);
        }else if(N > 9000 && N <= 10000){
            System.out.print(10000 - N);
        }
        

    }
}

Measured memory_bytes: 35560
#include <bits/stdc++.h>
#include <string>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define jai_shree_ram  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, a, b, d) for (int i = a; i <= b; i += d)
#define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
#define pb push_back
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define endl '\n'
const int MAX = 1e5 + 5;
const int MOD = 1e9 + 7;
////////////////////////////////

double dp[3000][3000];

int32_t main(){
    jai_shree_ram
    int n;
    cin >> n;
    double p[n+1];
    rep(i,1,n,1) cin >> p[i];
    dp[0][0] = 1;
    rep(i,1,n,1){
        dp[i][0] = dp[i-1][0] * (1 - p[i]);
        rep(j,1,i,1){
            dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1 - p[i]);
        }
    }
    double ans = 0;
    int ls = (n+1)/2;
    rep(i,ls,n,1) ans += dp[n][i];
    cout << setprecision(11)<< ans << fixed << endl;
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong H;
  cin >> H;

  vector<llong> v;
  while (H) {
    v.push_back(H);
    H >>= 1;
  }

  llong ans = 0;
  for (int i = 0; i < v.size(); ++i) {
    ans += pow(2, i);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string> 
using namespace std; 
int main(){ 

string a;
 
int ab[26]={}; 

int i; 

while(getline(cin,a)){ 
for(i=0;i<a.size();i++){ 
 if(a[i]>='a'&&a[i]<='z') ab[a[i]-'a']++;
 else if(a[i]>='A'&&a[i]<='Z') ab[a[i]-'A']++;
}

//cout << a << endl;

}

for(i=0;i<26;i++){ 
cout << (char)('a'+i) << " : " << ab[i] << endl;
}

return 0;
} 


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <queue>
#include <list>
#include <set>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 1ULL << 31 - 1;
const ll linf = 1ULL << 63 - 1;
const string nilstr("");

char encode(char c) {
    return c >= 'A' && c <= 'Z' ? c - 'A' : c - 'a' + (char) 26;
}

char decode(char i) {
    return i < 26 ? i + 'A' : i - (char) 26 + 'a';
}

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

struct uv {
    int a, b;
    bool operator<(const uv &x) const {
        if (a == x.a) return b < x.b;
        return a > x.a;
    }
};

set<int> cut;

bool iscut(uv x) {
    if (cut.empty()) return false;
    auto v = cut.lower_bound(x.a);
    if (v == cut.end()) return false;
    return (*v < x.b);
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<uv> bri(m);
    for (auto &i:bri) cin >> i.a >> i.b;
    sort(bri.begin(), bri.end());
    int ans = 0;
    for (auto i:bri) {
        if (iscut(i)) continue;
        ans++;
        cut.insert(i.a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(ll i=0;i<(ll)(s.size());++i) {
    cout << s[i];
    if(i == (ll)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
signed main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n, m; cin >> n >> m;
  vector<vector<ll>> g(n);
  for(ll i=0;i<m;++i) {
    ll a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll q; cin >> q;
  vector<ll> v(q), d(q), c(q);
  for(ll i=0;i<q;++i) {
    cin >> v[i] >> d[i] >> c[i];
    v[i]--;
  }
  reverse(v.begin(), v.end());
  reverse(d.begin(), d.end());
  reverse(c.begin(), c.end());
  vector<vector<ll>> dp(n, vector<ll>(11, INF));
  for(ll i=0;i<q;++i) {
    queue<P> que;
    vector<bool> sel(n);
    que.push({v[i], d[i]});
    sel[v[i]] = true;
    for(ll j=0;j<=d[i];++j) {
      dp[v[i]][j] = min(dp[v[i]][j], i);
    }
    while(!que.empty()) {
      ll nowv = que.front().first, nowd = que.front().second; que.pop();
      for(ll j=0;j<(ll)(g[nowv].size());++j) {
        ll nextv = g[nowv][j];
        if(!sel[nextv]) {
          sel[nextv] = true;
          if(nowd == 1) {
            dp[nextv][0] = min(dp[nextv][0], i);
            continue;
          }
          if(dp[nextv][nowd-1] < i) continue;
          for(ll k=0;k<=nowd-1;++k) {
            dp[nextv][k] = min(dp[nextv][k], i);
          }
          que.push({nextv, nowd-1});
        }
      }
    }
  }
  for(ll i=0;i<n;++i) {
    if(dp[i][0] == INF) {
      cout << 0 << endl;
    } else {
      cout << c[dp[i][0]] << endl;
    }
  }
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;


class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

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


    CumulativeSum dcs(n), mcs(n), ccs(n);
    rep(i, n) {
        char c = s[i];
        if (c == 'D') dcs.set(i, 1);
        else if (c == 'M') mcs.set(i, 1);
        else if (c == 'C') ccs.set(i, 1);
    }
    dcs.calculate();
    mcs.calculate();
    ccs.calculate();

    // あるCが自分の左に何個Mを持っているか
    CumulativeSum sum_cs(n);
    rep(i, n) {
        if (s[i] != 'C') continue;
        sum_cs.set(i, mcs.getSum(i - 1));
    }
    sum_cs.calculate();

    // DMC
    // Dから見てK以内にあるMの数と
    // Dから見てK以外にあるCの数

    rep(_, q) {
        int k;
        cin >> k;

        ll ans = 0;
        rep(i, n) {
            if (s[i] != 'D')continue;
            ll all = sum_cs.getSectionSum(i, min(i + k - 1, n));
            ll left_m = mcs.getSectionSum(0, i);
            ll inner_c = ccs.getSectionSum(i, min(i + k - 1, n));
            ll sub = left_m * inner_c;
            ll now = all - sub;
            ans += now;
        }
        cout << ans << endl;

/*
        rep(i, n) {
            if (s[i] != 'M') continue;
            ll l = dcs.getSectionSum(0, i - 1);
            ll r = ccs.getSectionSum(i + 1, n);

            ll now = l * r;
            all += now;
        }

        ll sub = 0;
        rep(i, n - k + 1) {
            if (s[i] != 'D') continue;
            ll m = mcs.getSectionSum(i, i + k);
            ll c = dcs.getSectionSum(i + k, n);

            ll now = m * c;
            sub += now;
        }
        ll ans = all - sub;
        */

    }

}

Measured memory_bytes: 66788
#include<stdio.h>
#include<math.h>

int main(){

    int N, D;
    scanf("%d%d", &N, &D);

    int x[N * D];
    for (int i = 0; i < N * D; i++){
        scanf("%d", &x[i]);
    }

    int count = 0;

    for (int i = 0; i < N - 1; i++){
        for (int j = i + 1; j < N; j++){

            float dis_sq = 0;
            for (int k = 0; k < D; k++){
                dis_sq += (x[i * D + k] - x[j * D + k]) * (x[i * D + k] - x[j * D + k]);
            }

            if(ceil(sqrt(dis_sq)) == floor(sqrt(dis_sq))){
                count += 1;
            }
        }
    }

    printf("%d", count);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int main()
{
	int N,M;
	cin >> N;
	int a;
	vector<bool> color(9,false);
	int saikyo = 0;
	for(int i = 0; i < N; i++)
	{
		cin >> a;
		if(1 <= a && a <= 399) color[0] = true;
		if(400 <= a && a <= 799) color[1] = true;
		if(800 <= a && a <= 1199) color[2] = true;
		if(1200 <= a && a <= 1599) color[3] = true;
		if(1600 <= a && a <= 1999) color[4] = true;
		if(2000 <= a && a <= 2399) color[5] = true;
		if(2400 <= a && a <= 2799) color[6] = true;
		if(2800 <= a && a <= 3199) color[7] = true;
		if(a >= 3200) color[8] = true,saikyo++;
	}
	int min = 0;
	int max = 0;
	for(int i = 0; i < 8; i++)
	{
		if(color[i]) min++;
	}
	if(color[8]) max = min+saikyo;
	else max = min;
	if(min ==0 && color[8]) min = 1,max = saikyo;
	cout << min << " " << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1777777777;
// constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

using ld = long double;

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

    int N;
    cin >> N;
    vector<ld> p(N);
    for(int i = 0; i < N; ++i)  cin >> p[i];

    vector<vector<ld>> dp(N + 1, vector<ld>(N + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j <= i; ++j){
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        }
    }

    ld ans = 0;
    for(int i = (N + 1) / 2; i <= N; ++i){
        ans += dp[N][i];
    }
    cout << fixed << setprecision(15);
    cout << ans << endl;
}

Measured memory_bytes: 144272
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string A,B,C; cin>>A>>B>>C;
    ll turn=0; //A
    
    while(1){
        if(turn==0 && sz(A)==0){
            cout<<"A"<<endl;
            return 0;
        }
        if(turn==1 && sz(B)==0){
            cout<<"B"<<endl;
            return 0;
        }
        if(turn==2 && sz(C)==0){
            cout<<"C"<<endl;
            return 0;
        }
        
        char tmp;
        if(turn==0){
            tmp=A[0];
            A.erase(0,1);
        }
        if(turn==1){
            tmp=B[0];
            B.erase(0,1);
        }
        if(turn==2){
            tmp=C[0];
            C.erase(0,1);
        }
        
        if(tmp=='a') turn=0;
        else if(tmp=='b') turn=1;
        else turn=2;
    }
}


Measured memory_bytes: 3608
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define INF 10000;
using namespace std;

int divide(vector<vector<int>> c, int K){
    vector<int> tmp1(c[0].size());
    vector<int> tmp2(c[0].size());
    vector<int> zero(c[0].size());
    int cut=0;
    for (int i = 0; i < c.size(); i++){
        int m=0;
        for (int j = 0; j < c[0].size(); j++){
            tmp1[j]+=c[i][j];
            m=max(m,tmp1[j]);
        }
        if(m<=K){
            tmp2=tmp1;
        }else{
            if(tmp2==zero)return INF;
            cut++;
            tmp1=c[i];
            tmp2.assign(c.size(),0);
        }
    }
    return cut;
}

int main() {
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<int>> S(H,vector<int>(W));
    for (int i = 0; i < H; i++){
        string s;
        cin >> s;
        for (int j = 0; j < W; j++){
            S[i][j]=(int)(s[j]-'0');
        }
    }
    int ans=INF;
    for (int i = 0; i < (1<<(H-1)); i++){
        bitset<10> bit(i);
        int c_num=bit.count()+1;
        vector<vector<int>> c(W,vector<int>(c_num));
        int c_index=0;
        for (int j = 0; j < H; j++){
            for (int k = 0; k < W; k++){
                c[k][c_index]+=S[j][k];
            }
            if(bit.test(j))c_index++;
        }
        ans=min(ans,(int)bit.count()+divide(c,K));
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
n = int(raw_input())
s = range(1,14)
h = range(1,14)
c = range(1,14)
d = range(1,14)
 
for i in range(n):
    q,r = raw_input().split()
    if q == 'S':
        s[int(r)-1] = 0
    elif q == 'H':
        h[int(r)-1] = 0
    elif q == 'C':
        c[int(r)-1] = 0
    elif q == 'D':
        d[int(r)-1] = 0
 
a = 'S '
for i in range(13):
    if s[i] != 0:
        print a + str(s[i])
a = 'H '
for i in range(13):
    if h[i] != 0:
        print a + str(h[i])
a = 'C '
for i in range(13):
    if c[i] != 0:
        print a + str(c[i])
a = 'D '
for i in range(13):
    if d[i] != 0:
        print a + str(d[i])

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

count = 0
sn = {}
for i in range(n):
  s = list(input())
  check = "".join(sorted(s)) 
  if not check in sn:
    sn[check] = 1
  else :
    count += sn[check]
    sn[check] += 1
    
print(count)   

Measured memory_bytes: 22188
#include<cstdio>
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){

        ios::sync_with_stdio(false);
        cin.tie(0);

	int x;
	cin >> x;

	int a = x/500;
	int a_r = x%500;

	int b = a_r/5;

	cout << a*1000+b*5;



	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int n,m;
int func(int a){
	return a%n?a%n:n;
}
int main(){
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0)break;
		int temp = 0;
		bool flg[1001] = {false};
		for(int i = 1; i < n; i++){
			for(int j = 0; j < m; j++){
				temp++;
				if(flg[func(temp)] == false);
				else j--;
			}
			flg[func(temp)] = true;
		}
		for(int i = 1; i <= n; i++)if(flg[i] == false)cout << i << endl;
	}
	return 0;
}

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

int main() {
  // 整数
  int X;
  // 配列の長さ
  int Y;
  
  cin >> X >> Y;
  
  if (Y == 0) {
  	cout << X << endl;
    return 0;
  }
  
  vector<int> vec(Y);
  
  // 入力を受け取る
  for (int i = 0; i < Y; i++) {
    cin >> vec.at(i);
  }
  
  // 配列をソート
  sort(vec.begin(), vec.end());
  
	//配列に存在するか
    auto itr = find(vec.begin(), vec.end(), X);
  	size_t index = std::distance(vec.begin(), itr );
  
    if (index != vec.size()) { 
      // 発見できたとき  
      for (int i = 1; i < 101; i++) {
      	//配列に存在するか
    	auto itr = find(vec.begin(), vec.end(), X - i);
  		size_t index = std::distance(vec.begin(), itr);
        
        if (index != vec.size()) { // 発見できたとき  
      	  auto itr = find(vec.begin(), vec.end(), X + i);
  		  size_t index = std::distance(vec.begin(), itr);
          
          if (index != vec.size()) {
          	continue;
          } else {
            cout << X + i << endl;
    		return 0; 
          }
  		} else { // 発見できなかったとき
      		cout << X - i << endl;
    		return 0; 
        }      
 	 }
  	} else { // 発見できなかったとき
		cout << X << endl;
    	return 0; 
    }
  
}


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

using namespace std;

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

  int n, len;
  cin >> n >> len;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (auto &x : a) {
    cout << x;
  }
  cout << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int main(){
    int T[3],c=0;
    cin>>T[0]>>T[1]>>T[2];
    sort(T,T+3);
    c+=T[2]-T[1];
    c+=T[1]-T[0];
    cout<<c<<endl;
    return 0;
}


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

int main() {
    int H, W;
    string sharp;
    cin >> H >> W;

    sharp = "";
    for (int i = 0; i < W; i++) {
        sharp += "#";
    }
    cout << "#" << sharp << "#" << endl;

    for (int i = 0; i < H; i++) {
        vector<char> vec(W);
        for (int j = 0; j < W; j++) {
            cin >> vec.at(j);
        }
        cout << "#";
        for (int j = 0; j < W; j++) {
            cout << vec.at(j);
        }
        cout << "#" << endl;
    }

    cout << "#" << sharp << "#" << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    k = int(input())

    res = 1
    idx = 0
    for i in range(len(s)):
        if s[i] != "1":
            res = s[i]
            idx = i + 1
            break

    if k < idx:
        print(1)
    else:
        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
#include <cstdio>
#include <vector>

template <class T> void chmin(T &a, const T &b) {
  if (b < a)
    a = b;
}

template <class T> void chmax(T &a, const T &b) {
  if (a < b)
    a = b;
}

int main() {
  using u64 = unsigned long long;

  int n;
  scanf("%d", &n);
  std::vector<u64> a(n);
  u64 sum = 0;
  for (u64 &e : a) {
    scanf("%llu", &e);
    sum ^= e;
  }
  for (u64 &e : a)
    e &= ~sum;

  std::vector<u64> base;
  for (u64 e : a) {
    for (const u64 b : base)
      chmin(e, e ^ b);
    if (e != 0)
      base.push_back(e);
  }

  u64 ans = 0;
  for (const u64 b : base)
    chmax(ans, ans ^ b);

  printf("%llu\n", sum + ans * 2);
}


Measured memory_bytes: 1152
# coding: utf-8
# Your code here!
import sys, collections, bisect, math, itertools, heapq
from fractions import gcd 
#input = sys.stdin.readline #文字列入力のときは注意

n,k,q = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
aa = sorted(a)
a += [0]

ans = 10**9+1
mmm = 0
for i,m in enumerate(aa):
#    print(i,m)
    if mmm == m: continue
    hh = [] 
    mae = 0
    for j,aj in enumerate(a):
        if aj < m:
            h=a[mae:j]
#            print(h,"h",j,mae)
            heapq.heapify(h)
            for _ in range(j-mae-k+1):
                hh.append(heapq.heappop(h))
            mae = j+1
    mmm = m
    
#    print("hh",hh)
    if len(hh) < q: break
    else:
        hh.sort()
        ans = min(ans, hh[q-1]-hh[0])
            
print(ans)
        




Measured memory_bytes: 84952
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    int sum = 0;
    rep(i,3) if (s[i] == 'R') sum++;
    if (s[1] == 'S' && sum == 2) cout << 1 << endl;
    else cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

double PI = acosl(-1);
int a, b, h, m;

vector<double> getPoints(double thetha, int x){
   vector<double> ans;

   double X, Y;
   if (thetha <= 90){
      thetha = 90 - thetha;
      X = x * cosl(thetha);     
      Y = x * sinl(thetha);
   }
   else if (thetha <= 180){
      thetha -= 90;
      X = x * cosl(thetha);     
      Y = -x * sinl(thetha);
   }
   else if (thetha <= 270){
      thetha = 270 - thetha;
      X = -x * cosl(thetha);     
      Y = -x * sinl(thetha);
   }
   else{
      thetha = thetha - 270;
      X = -x * cosl(thetha);     
      Y = x * sinl(thetha);
   }

   ans.push_back(X);
   ans.push_back(Y);
   return ans;
}

void solve(){
   cin >> a >> b >> h >> m;

   double thetha = ((h + (m / 60.0)) / 12.0) * 2 * PI;
   double delta = (m / 60.0) * 2 * PI;

   auto hr = getPoints(thetha, a);
   auto min = getPoints(delta, b);

   double distance = (hr[0] - min[0]) * (hr[0] - min[0]) + (hr[1] - min[1]) * (hr[1] - min[1]);
   distance = sqrtl(distance);

   cout << fixed << setprecision(15);
   cout<<distance;
}

int32_t main(){_
   
   int t = 1;
   //cin >> t;

   while(t--){
     solve();
     cout << endl;
   }
   

   return 0;
}

Measured memory_bytes: 4132