akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n , a , b , c , d ,f1 = 0 , f2 = 0,f3=0 ;
	cin >> n >> a >> b >> c >> d ;
	a-- ; b-- ; c-- ; d-- ;
	string s ;
	cin >> s ;
	int i = b ;
	while(true){
		if(s[i + 1] == '.'){
			i += 1 ;
			if(i == d){
				f1 = 1;
				break ;
			}
			continue ;
		}
		if(s[i + 2] == '.'){
			i += 2 ;
			if(i == d){
				f1 = 1;
				break ;
			}
			continue ;
		}
		if(i > d)
			break ;
		break ;
	}
	i = a ;
	while(true){
		if(s[i + 1] == '.'){
			i += 1 ;
			if(i == c){
				f2 = 1;
				break ;
			}
			continue ;
		}
		if(s[i + 2] == '.'){
			i += 2 ;
			if(i == c){
				f2 = 1;
				break ;
			}
			continue ;
		}
		if(i > c)
			break ;
		break ;
	}
	if(c > d){
		for(int j = b - 1 ; j <= d - 1 ; j++){
			if(s[j] == '.' && s[j + 1] == '.' && s[j + 2] == '.'){
				f3 = 1;
			}
		}
		// cout << f1 << " " << f2 << " "<< f3 ;
		if(f1 && f2 && f3){
			cout << "Yes" ;
		}
		else
			cout << "No" ;
	}
	else{
		if(f1 & f2){
			cout << "Yes" ;
		}
		else
			cout << "No" ;
	}
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    int kai = 1;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    double as;
    double ans = 0;
    rep(i,n){
        kai *= i+1;
    }
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    rep(i,n){
        rep(j,n){
            if(i == j){
                continue;
            }
            else{
                as = (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
                ans += sqrt(as);
            }
        }
    }
    ans *= (double)kai/n;
    ans /= (double)kai;
    printf("%.8f\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] x = new int[N];
		for(int i=0;i<N;i++){
			x[i] = sc.nextInt();
		}
		int cnt = 0;
		int dis = 0;
		for(int ind: x){
		    int eql = ind;
		    if(ind>K-ind)
		        eql = K-ind;
		    dis += eql*2;
		}
	    System.out.println(dis);
	}
}


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

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

const long long MOD = 1000000007;

int main(){
  ll n,a,b;
  ll ans = 0;
  cin >> n >> a >> b;
  ll t = n/(a+b);
  n = n % (a+b);
  ans = a*t;
  ans += min(a,n);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define df 0
typedef long int ll;
const int MOD=1e9+7;

ll pow3(int a,int len);
ll count(string& S,string str,int cnt);



int main(){
  if(df) printf("*debug mode*\n");
  string S; cin >> S;
  int cnt=0;
  for(auto c: S){
    if(c=='?')cnt++;
  }
  ll s=0;
  (s+=count(S,"???",cnt))%=MOD;
  (s+=count(S,"??C",cnt))%=MOD;
  (s+=count(S,"?B?",cnt))%=MOD;
  (s+=count(S,"A??",cnt))%=MOD;
  (s+=count(S,"?BC",cnt))%=MOD;
  (s+=count(S,"A?C",cnt))%=MOD;
  (s+=count(S,"AB?",cnt))%=MOD;
  (s+=count(S,"ABC",cnt))%=MOD;

  cout << s;
}

ll pow3(int a,int len){
  static vector<ll> pow(len+1,0);
  if(a<=0){
    return 1;
  }
  if(pow[a]!=0) return pow[a];
  ll s;
  if(a%2){
    s=pow3(a-1,len);
    if(df)printf("3^%d->%ld\n",a-1,s);
    pow[a]=s*3%MOD;
    return pow[a];
  }
  s=pow3(a/2,len);
  pow[a]=s*s%MOD;
  if(df)printf("3^%d->%ld\n",a/2,s);
  return pow[a];
}

ll count(string& S,string str,int cnt){
  int len=S.size();
  ll s=0, a[3][len];
  if(str.at(0)==S.at(0))a[0][0]=1; else a[0][0]=0;
  a[1][0]=a[2][0]=0;
  if(df) cout << str << "\n";
  for(int i=1;i<len;i++){
    char c=S.at(i);
    for(int j=0;j<3;j++){
      if(c==str.at(j)){
	a[j][i]=a[j][i-1]+((j==0)?1:a[j-1][i-1]);
	a[j][i]%=MOD;
      }else{
	a[j][i]=a[j][i-1];
      }
      if(df) printf("%ld ",a[j][i]);
    }
    if(df) printf("\n");
  }
  for(auto a: str) if(a=='?')cnt--;
  return a[2][len-1]*pow3(cnt,len);
}

/// confirm df==0 ///

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <cstring>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 998244353;
const int ms = 3030;

int n, m;
int memo[ms][ms];

long long dp(int i, int j) {
	if(i > n || j > m) return 0;
	if(i == n && j == m) return 1;
	int &ans = memo[i][j];
	if(ans != -1) return ans;
	else return ans = (int) ((dp(i+1, j) * j + dp(i, j+1) * i - dp(i+1, j+1) * i * j % MOD + MOD) % MOD);
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int a, b;
	std::cin >> a >> b >> n >> m;
	memset(memo, -1, sizeof memo);
	std::cout << dp(a, b) << '\n';
}

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

using namespace std;

int tem, temy;

struct px
{
  int a, b;
}x[2000000];

bool cmp(px x,px y)
{
  return x.b < y.b;
}

int main()
{
  int n,sum=1,mi;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    cin>>tem>>temy;
    x[i].a = tem - temy;
    x[i].b = tem + temy;
  }
  sort(x+1,x+n+1,cmp);
  mi=x[1].b;
  int j=1;
  while(j<=n)
  {
    j++;
    if(x[j].a>=mi) {
      sum++;
      mi=x[j].b;
      }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
 
int main(void) {
  char str[100000];
  int n = 0, m = 0;
  int a, b, num;
 
  scanf("%s", &str);
   for (a = 0; str[a] != '\0'; ++a) {
    if (a % 2 == 0) {
      if ('0' != str[a])
        n=n+1;
    } else {
      if ('1' != str[a])
        n=n+1;
    }
   }
  for (b = 0; str[b] != '\0'; ++b) {
    if (b % 2 == 0) {
      if ('1' != str[b])
        m=m+1;
    } else {
      if ('0' != str[b]) 
        m=m+1;
    } }
   if (n < m)
    printf("%d\n", n);
  else
    printf("%d\n", m);
 
  return 0;
  
}

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

int main() {
    ld H, W;
    ll ans;
    cin >> H >> W;
    if (H == 1 || W == 1) ans = 1;
    else ans = ceil(H * W / 2);
    cout << ans << endl;
}


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s; cin>>s;
    int n = (int)s.size();
    vector<int> r(n, 0), l(n, 0), ans(n, 0);
    for(int i=1; i<n; ++i){
        r[i] = s[i] == 'R' ? 0: r[i-1] + 1;
        l[n-i-1] = s[n-i-1] == 'L' ?  0 : l[n-i] + 1;
    }
    for (int i=0; i<n; ++i){
        if(s[i] == 'L'){
           if (r[i]&1) ans[i-r[i]+1]++;
           else  ans[i-r[i]]++;
        }else{
            if (l[i]&1) ans[i+l[i]-1]++;
            else  ans[i+l[i]]++;
        }
    }
    for (int i :ans) cout<<i<<" "; cout<<endl;
    return 0;
}


Measured memory_bytes: 1872
/*A - ∴ (Therefore)*/

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

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int num;
	cin >> num;

	int n = num % 10;

	if(n == 2 or n == 4 or n == 5 or n == 7 or n == 9)
		cout << "hon";
	else if(n == 0 or n == 1 or n == 6 or n == 8)
		cout << "pon";
	else
		cout << "bon";

	return 0;
}

Measured memory_bytes: 3604
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";

int main() {
	cin >> S;
	for(int i = 0; i < S.size(); i++) {
		if(S[i] == 'R' && (i & 1)) {
			printf("No\n");
			return 0;
		}
		else if(S[i] == 'L' && (i % 2 == 0)) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#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 ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	VI a(n), b(n), c(n - 1);
	FOR(i, 0, n) cin >> a[i];
	FOR(i, 0, n) cin >> b[i];
	FOR(i, 0, n - 1) cin >> c[i];
	int ans = 0;
	FOR(i, 0, n) ans += b[i];
	FOR(i, 0, n - 1)
	{
		int p1 = 0, p2 = 0;
		FOR(x, 0, n) if (a[x] == i + 1) p1 = x;
		else if (a[x] == i + 2) p2 = x;
		if (p2 == p1 + 1) ans += c[i];
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

struct Pat
{
	i64 val[4];
};

Pat operator+(const Pat &a, const Pat &b)
{
	Pat ret;
	for (int i = 0; i < 4; ++i) {
		ret.val[i] = (a.val[i] + b.val[i]) % MOD;
	}
	return ret;
}

Pat operator-(const Pat &a, const Pat &b)
{
	Pat ret;
	for (int i = 0; i < 4; ++i) {
		ret.val[i] = (a.val[i] - b.val[i] + MOD) % MOD;
	}
	return ret;
}
Pat operator*(const Pat &a, i64 b)
{
	Pat ret;
	for (int i = 0; i < 4; ++i) {
		ret.val[i] = (a.val[i] * b) % MOD;
	}
	return ret;
}

struct Matr
{
	i64 val[4][4];
};

Matr operator*(const Matr& a, const Matr& b)
{
	Matr ret;
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			i64 v = 0;
			for (int k = 0; k < 4; ++k) v += a.val[i][k] * b.val[k][j];
			ret.val[i][j] = v % MOD;
		}
	}
	return ret;
}

Pat operator*(const Matr& a, const Pat& b)
{
	Pat ret;
	for (int i = 0; i < 4; ++i) {
		i64 v = 0;
		for (int j = 0; j < 4; ++j) {
			v += a.val[i][j] * b.val[j];
		}
		ret.val[i] = v % MOD;
	}
	return ret;
}

const Matr unit = {
	{
		{1, 0, 0, 0},
		{0, 1, 0, 0},
		{0, 0, 1, 0},
		{0, 0, 0, 1}
	}
};

Matr matpow(const Matr& m, int p)
{
	if (p == 0) {
		return unit;
	}
	if (p == 1) {
		return m;
	}
	Matr tmp = matpow(m, p / 2);
	tmp = tmp * tmp;
	if (p % 2 == 1) {
		tmp = tmp * m;
	}
	return tmp;
}

const Matr trans = {
	{
		{ 0, 1, 0, 0 },
		{ 0, 0, 1, 0 },
		{ 0, 0, 0, 1 },
		{ 1, MOD - 1, 2, 3 }
	}
};

const Pat base = {
	{ 0, 1, 5, 18 }
};

int N, M, X[101010];
i64 dp[101010];

int main()
{
	scanf("%d%d", &N, &M);
	X[0] = 0;
	for (int i = 1; i <= M; ++i) scanf("%d", X + i);
	X[M + 1] = N;

	M += 2;
	dp[0] = 1;
	Pat dec = base;

	for (int i = 1; i < M; ++i) {
		/*
		for (int j = 0; j < i; ++j) {
			ADD(dp[i], MOD - dp[j] * (matpow(trans, X[i] - X[j]) * base).val[0] % MOD);
		}
		*/
		dec = matpow(trans, X[i] - X[i - 1]) * dec;
		dp[i] = MOD - dec.val[0];
		dec = dec + base * dp[i];
	}

	printf("%lld\n", (dec.val[0]) % MOD);

	return 0;
}


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

int main(){
  int n,q,k;
  cin >> n >> k >> q;
  map<int,int>toku;
  int a;
  for(int i=0;i<q;i++){
    cin >> a;
    toku[a-1]++;
  }
  for(int i=0;i<n;i++){
    if(toku[i]+k-q<=0){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 8252
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;


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

    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == N) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    x = [int(i) for i in input().split()]
    newx = sorted(x)
    ans = dict()
    for i,xx in enumerate(newx):
        if i+1 <= n//2:
            ans[xx] = newx[n//2]
        else:
            ans[xx] = newx[n//2-1]
    for xx in x:
        print(ans[xx])

if __name__ == '__main__':
    main()


Measured memory_bytes: 34484
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S, T;
  cin >> S >> T;
  int q;
  cin >> q;
  int Ns = S.size(), Nt = T.size();
  vector<int> Vs(Ns+1), Vt(Nt+1);
  rep(i, Ns)
    Vs[i+1] = Vs[i] + (S[i] == 'A' ? 1 : 2);
  rep(i, Nt)
    Vt[i+1] = Vt[i] + (T[i] == 'A' ? 1 : 2);
  rep(i, q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int vs = (Vs[b] - Vs[a-1]) % 3, vt = (Vt[d] - Vt[c-1]) % 3;
    if(vs == vt)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}



Measured memory_bytes: 1664
N,M=map(int, input().split())

max = 0
min = 0

for _ in range(M):
    L,R = map(int, input().split())

    if min <= L:
        min = L
    elif min == 0:
        min = L

    if max >= R:
        max = R
    elif max == 0:
        max = R

ans = max - min + 1

if ans < 0:
    ans = 0

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(double (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    double n;
    cin >> n;

    eFOR(a, 1, 3500)eFOR(b, 1, 3500) {
        double c = (n * a * b) / (4 * a * b - n * a - n * b);
        if (c > 0 && c == (int)c) {
            cout << (int)a << " " << (int)b << " " << (int)c << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] an = in.nextIntArray(n);

			Arrays.sort(an);
			if (n % 2 == 0) {
				for (int i = 0; i < n; i += 2) {
					if (an[i] == an[i + 1]) {
						continue;
					} else {
						out.println(0);
						return;
					}
				}
			} else {
				for (int i = 1; i < n; i += 2) {
					if (an[i] == an[i + 1]) {
						continue;
					} else {
						out.println(0);
						return;
					}
				}
			}

			long ans = 1;
			int half = n / 2;
			for (int i = 0; i < half; i++) {
				ans = ans * 2 % modP;
			}
			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 33248
#include<cstdio>
#include<algorithm>
int aa[10000];
int main(){
  int n, m, x;
  int a[1000];
  scanf("%d%d%d", &n, &m, &x);
  for(int i = 0; i < m; i++){
    scanf("%d", &a[i]);
    aa[a[i]]=1;
  }
  int ans1=0,ans2=0;
  for(int i = x; i <n; i++) ans1 += aa[i];
  for(int i = x; i >= 0; i--) ans2 += aa[i];
  printf("%d\n", std::min(ans1, ans2));
         }

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {

    ll mod = 1000000007;
    ll N;
    cin >> N;
    ll A[100000] = {0};
    rep(i,N){
        ll a;
        cin >> a;
        A[a]++;
    }
    
    ll out = 0;
    bool isExist = true;
    ll tmp = 0;
    while(tmp<N){
        if(N%2==0&&tmp==0) tmp = 1;
        if(tmp==0){
            if(A[tmp]==1) tmp += 2;
            else{
                isExist = false;
                break;
            }
        }
        else{
            if(A[tmp]==2) tmp += 2;
            else{
                isExist = false;
                break;
            }
        }
    }
    
    if(isExist){
        out = 1;
        rep(i,N/2){
            out = (out*2)%mod;
        }
    }
    
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 4384
#include <iostream>
#include <vector>
#include <map>

struct UnionFind {
    std::vector<int> par;
    std::vector<int> sizes;

    UnionFind(int n) : par(n), sizes(n, 1) {
        for (int i = 0; i < n; i++)
            par[i] = i;
    }

    int find(int x) {
        return x == par[x] ? x : par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if (x == y)
            return;

        if (sizes[x] > sizes[y])
            std::swap(x, y);

        par[x] = y;
        sizes[y] += sizes[x];
    }

    int size(int x) {
        return sizes[find(x)];
    }
};

int main() {
    const int XY_MAX = 100000;

    int N;
    std::cin >> N;

    UnionFind uf(XY_MAX * 2);
    for (int i = 0; i < N; i++) {
        int x, y;
        std::cin >> x >> y;
        uf.unite(x - 1, y - 1 + XY_MAX);
    }

    std::map<int, int> x_count, y_count;
    for (int i = 0; i < XY_MAX; i++)
        x_count[uf.find(i)] += 1;
    for (int i = XY_MAX; i < XY_MAX * 2; i++)
        y_count[uf.find(i)] += 1;

    long long res = 0;
    for (int i = 0; i < XY_MAX * 2; i++)
        res += 1LL * x_count[i] * y_count[i];
    std::cout << res - N << "\n";
}

Measured memory_bytes: 20608
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repr(i,n) for (int i = 0; i < (f); --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int func(ll a, ll b, ll c){
  if((a%2==1) || (b%2)==1 || (c%2) == 1) return 0;
  if((a == b && b == c)) return -1;
  return func((b+c)/2, (c+a)/2, (a+b)/2) + 1;
}

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  cout << func(a,b,c) << endl;
  return 0;
}

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

int main(){
  	long A, B, C, K, ans=0;
  	cin >> A >> B >> C >> K;
  	if(K>=A){
    	K-=A;
      	ans+=A;
    }else{
    	ans+=K;
      	cout << ans << endl;
      	return 0;
    }
  	
  	if(K>=B){
    	K-=B;
    }else{
    	cout << ans << endl;
      	return 0;
    }
  
  	if(K>=C){
    	K-=C;
      	ans-=C;
    }else{
    	ans-=K;
      	cout << ans << endl;
      	return 0;
    }
  	
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#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 REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////

/*（๑•﹏•๑｀) */
int main() {
    int N; cin >> N;
    vector<ll> A(N);
    int minnum = 0;
    ll absum = 0;
    ll abmin = 1e10;

    REP(i,N){
        cin >> A[i];
        absum += abs(A[i]);
        if (A[i] < 0) minnum++;
        if (abs(A[i]) < abmin) abmin = abs(A[i]);
    }

    ll ans = 0;

    if (minnum % 2 == 0) {
        ans = absum;
    }else{
        ans = absum - 2 * abmin;
    }



    cout << ans << "\n";


}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod=1000000007;
//head

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

    ll a, b, x;
    cin >> a >> b >> x;
    ll nxta = ((a + x - 1) / x) * x;
    ll lstb = (b/x)*x;
    cout << (lstb - nxta) / x + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
//#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=2019;
const ll inf=1e15+5;
const ll N=1e5+10;

int main()
{
	boost;
	ll l,r;
	cin>>l>>r;
	set<ll> s;
	for(ll i=l;i<=r and (i-l+1)<=(mod+3); i++)
	{
		s.insert(i%mod);
	}
	vector<ll> v;
	for(auto i:s) v.pb(i);
	ll n=v.size();	
	ll ans=inf;
	for(ll i=0;i<n;i++) for(ll j=i+1;j<n;j++) 	ans=min(ans,(v[i]*v[j])%mod);
	cout<<ans;	
	return 0;
} 


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
#define lg length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<ll,ll> a,pair<ll,ll> b){
    if(a.se!=b.se)
        return a.se<b.se;
    else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(int argc, char * argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("big.txt", "r", stdin);
    //freopen("out3.txt", "w", stdout);
    //------------------------------
    ll n,x,t;cin>>n>>x>>t;
    ll ans = n/x;
    if(n%x!=0)ans++;
    cout<<ans*t<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------












































Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

using namespace std;
#define N 300010
ll a[N],n;
bool solve(ll x){
  vector<ll> v;
  for(int i=0;i<n;i++)v.push_back(a[i]);
  while(v.size()>1){
    ll w=v[v.size()-1];
    ll b=v[v.size()-2];
    if(b<w||w<x)v[v.size()-3]+=w-b;
    v.pop_back();v.pop_back();
  }
  return x<=v[0];
}
int main(){
    cin>>n;
    ll vl=0,vr=0;
    for(int i=0;i<n;i++){
      cin>>a[i];
      if(i&1)vl+=a[i];
      else vr+=a[i];
    }
    if(n&1){
      ll l=0,r=1e15,m;
      while(l<r-1){
	m=(l+r)/2;
	if(solve(m))l=m;
	else r=m;
      }
      cout<<vl+l<<" "<<vr-l<<endl;
    }
    else cout<<max(vl,vr)<<" "<<min(vl,vr)<<endl;
    return 0;
}


Measured memory_bytes: 10892
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
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 long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    char c[3][3]={};
    
     rep (i,3)rep(j,3)cin >> c[i][j];
     
     cout << c[0][0]<<c[1][1]<<c[2][2] << endl;
     
    
    
    
    
    
    
    

    
/////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int dx[] = { 1,-1,0,0 };
const int dy[] = { 0,0,-1,1 };
const int inf = 1e9+9;
const int maxn = 505;

int A[maxn];

int main()
{
#ifdef FOO_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,x;
    while (cin >> n >> x) {
        FOR(i,0,n)
            cin >> A[i];
        sort(A,A+n);
        int ans = 0;
        FOR(i,0,n) if (x >= 0) {
            if (x >= A[i]) {
                if (i == n-1 && A[i] != x)
                    ;
                else
                    ans++;
            }
            x -= A[i];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
using namespace std;
using i64 = int64_t;
template<class T, class F = plus<T>>
struct Fenwick {
    int n;
    vector<T> c;
    T init;
    F f;
    Fenwick(int n, F f = plus<T>(), T init = T())
        : n(n), c(n + 1, init), init(init), f(f) {}
    
    T sum(int i) const {
        T x = init;
        while (i > 0) {
            x = f(x, c[i]);
            i -= i & -i;
        }
        return x;
    }
    void add(int i, T x) {
        while (i <= n) {
            c[i] = f(c[i], x);
            i += i & -i;
        }
    }
};
string s;
int main() {
    cin >> s;
    int n = s.size();
    Fenwick<int> fen(n + 2);
    vector<int> pos[26];
    for (int i = 0; i < n; ++i) {
        pos[int(s[i] - 'a')].push_back(i + 1);
    }
    bool odd = n % 2 == 0;
    int mid = 2 * n;
    map<int, int> mp;
    for (int c = 0; c < 26; ++c) {
        int m = pos[c].size();
        if (m % 2 == 1) {
            if (odd) {
                cout << -1 << endl;
                return 0;
            } else {
                odd = true;
                mid = pos[c][m / 2];
            }
        }
        for (int i = 0; i < m / 2; ++i) {
            int j = m - i - 1;
            mp[pos[c][i]] = pos[c][j];
        }
    }
    for (int i = 1; i <= n; ++i) {
        fen.add(i, 1);
    }
    i64 ans = 0;
    for (auto p : mp) {
        int l = p.first, r = p.second;
        if (l > mid) ++ans;
        fen.add(l, -1);
        if (r > 0) fen.add(r, -1);
        ans += fen.sum(n) - fen.sum(r);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6788
#include <iostream>
#include <string>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 200001;

ll qy[100000] = {};
ll qx[100000] = {};
ll sp = 0;
ll tp = 0;

int main() {
	ll h, w; cin >> h >> w;
	char c[50][50];
	ll white = 0;
	rep(i, 0, h)rep(j, 0, w) {
		cin >> c[i][j];
		if (c[i][j] == '.')white++;
	}

	//sy sx 0,0
	//gy gx h-1,w-1
	ll d[50][50] = {};
	bool v[50][50] = {};
	rep(i, 0, h)rep(j, 0, w) {
		d[i][j] = 0;
		v[i][j] = false;
	}

	ll y[4] = { 0,1,-1,0 };
	ll x[4] = { 1,0,0,-1 };

	qy[sp] = 0;
	qx[sp] = 0;
	sp++;
	d[0][0] = 1;
	v[0][0] = true;

	while (sp > tp) {
		ll cury = qy[tp];
		ll curx = qx[tp];
		tp++;

		rep(i, 0, 4) {
			ll ny = cury + y[i];
			ll nx = curx + x[i];
			if (ny >= 0 && ny < h && nx >= 0 && nx < w && !v[ny][nx] && c[ny][nx] != '#') {
				d[ny][nx] = d[cury][curx] + 1;
				v[ny][nx] = true;
				qy[sp] = ny;
				qx[sp] = nx;
				sp++;
			}
		}
	}
	if (d[h - 1][w - 1] == 0) {
		cout << -1 << endl;
	}
	else {
		cout << white - d[h - 1][w - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List (reverse)

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

main :: IO ()
main = do
  n <- cReadLn
  print $ f n

f = length . show . snd . minPair

factors n = filter (n `divides`) $ factors' n

factors' :: Int -> [Int]
factors' n = [n', n'-1 .. 1]
  where
    n' = floor . sqrt . fromIntegral $ n

divides :: Int -> Int -> Bool
x `divides` y = rem x y == 0

minPair :: Int -> (Int, Int)
minPair n = (a,b)
  where
    (a,b) = if null (factors n)
              then (1,n)
              else (p,q)
    (p:_) = factors n
    q     = n `div` p

Measured memory_bytes: 1020
n=int(input())
num=[]
def dfs(s,x):
    if x==len(str(n)):
        return
    else:
        num.append(int(s+"3"))
        num.append(int(s+"5"))
        num.append(int(s+"7"))
        dfs(s+"3",x+1)
        dfs(s+"5",x+1)
        dfs(s+"7",x+1)
dfs("",0)
num=sorted(set(num))
ans=0
for i in num:
    if i<=n and str(i).count("3")*str(i).count("5")*str(i).count("7")!=0:
        ans+=1
print(ans)


Measured memory_bytes: 6804
/*----------------------------------------------------*
* लेखक --> अमित सिंह
* संस्थान --> राष्ट्रीय प्रौद्योगिकी संस्थान, कुरुक्षेत्र
*-----------------------------------------------------*/
   #include <bits/stdc++.h>
   using namespace std;
   #define ll long long
   #define w(t) int t; cin>>t; while(t--)
   #define fo(i,n) for(int i=0;i<n;i++)
   #define endl "\n" 
   #define MOD 1000000007
   void Tez(){
      ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
   }
   int main(){
      Tez();
      int n;
      cin>>n;
      vector<pair<int,int>>v;
      for(int i=0;i<n;i++){
         int x,y;
         cin>>x>>y;
         v.push_back({x,y});
      }
      string ans="No";
      for(int i=2;i<n;i++){
         if(v[i].first==v[i].second && v[i-1].first==v[i-1].second && v[i-2].first==v[i-2].second){
            ans="Yes";
            break;
         }
      }
      cout<<ans;
      return 0;
   }



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

int main() {
  int N, M, C;
  int A[21][21];
  int B[21];
  cin >> N >> M >> C;
  
  for (int i = 0; i < M; i++) cin >> B[i];

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int sum = C;
    for (int j = 0; j < M; j++) {
      sum += A[i][j] * B[j];
    }
    if (sum> 0) ans++; 
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>

using namespace std;


int main() {
	double x1, x2, y1, y2;
	double d;
	cin >> x1 >> y1 >> x2 >> y2;
	d = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
	printf("%.8f\n", d);
	
}

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

using namespace std;

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

  int ans = 0;
  for(int i=0; i<s.size(); i++){
    if( s.at(i) == t.at(i) ) ans += 1;
  }

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


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

int main () 
{
    int x, y;
    
    while (1)
    {
        std::cin >> x >> y;
        
        if (x == 0 && y == 0) break;
        
        if (x < y) std::cout << x << " " << y << std::endl;
        else std::cout << y << " " << x << std::endl;
        
    }
    
    return 0;
}


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

bool check_fizz_buzz(int n, string s){
	if(n % 15 == 0)
		return (s == "FizzBuzz");
	else if(n % 3 == 0)	
		return (s == "Fizz");
	else if(n % 5 == 0)
		return (s == "Buzz");
	
	for(unsigned int i = 0; i < s.size(); ++i)
		if(s[i] < '0' || s[i] > '9')
			return false;
			
	return (n == atoi(s.c_str()));
}

int main() {
	int n, m;
	string s;
	while(1){
		cin >> m >> n;
		if(m == 0 && n == 0)
			break;
		bool srv[1001] = {false};
		int now = 1 , count = 0;
		for(int i = 1; i <= n; ++i){
			cin >> s;
			if(count >= m - 1)
				continue;

			if(!check_fizz_buzz(i, s)){
				srv[now] = true;
				count++;
			}
			now++;
			while(srv[now])
				now++;
			if(now >= m + 1)
				now = 1;
			while(srv[now])
				now++;
		}
		int ans[1000] = {0};
		bool end = true;
		for(int i = 0; i < m && end; ++i){
			for(int j = 1; j <= m; ++j){
				if(!srv[j]){
					ans[i] = j;
					srv[j] = true;
					break;
				}
				if(j == m - 1)
					end = false;
			}
		}
			
		for(int i = 0; i < m; ++i){
			if(ans[i] == 0)
				continue;
			if(i)
				cout << " ";
			cout << ans[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>                                             
using namespace std;                                            
                                                                
int main(void) {                                                
  int S;                                                        
  cin >> S;                                                     
  int h = S/3600;                                               
  int m = S%3600/60;                                            
  int s = S%3600%60;                                            
  cout << h << ":" << m << ":" << s << endl;                    
  return 0;                                                     
}                               

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

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

#ifdef LOCAL
  #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

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

  for(char &c : str) {
    if(c == '9') {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main () {
  char o[51]={0};
  char e[51]={0};
  scanf("%s",o);
  scanf("%s",e);
  int i ;
  for(i=0;i<50;i++){
    if(o[i] != 0){
      printf("%c", o[i]);
    }
    if(e[i] != 0){
      printf("%c", e[i]);
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N, Q = map(int, input().strip().split())
connections = [[] for _ in range(N)]

for i in range(N-1):
    a, b = map(int, input().strip().split())
    connections[a-1].append(b-1)
    connections[b-1].append(a-1)

counter = [0 for _ in range(N)]

for i in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x
search_list = [0, ]
is_visit = [False for _ in range(N)]

while len(search_list) > 0:
    now = search_list.pop()
    is_visit[now] = True
    now_count = counter[now]
    for p in connections[now]:
        if is_visit[p]:
            continue
        search_list.append(p)
        counter[p] += now_count

print(" ".join(map(str, counter)))


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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	char s[200001];
	scanf("%s",s);
	ll sum=0;
	for(int i=0;i<strlen(s);++i){
		sum+=s[i]-'0';
	}

	if(sum%9==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


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

int main() {
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if (r <= x&&x <= W - r) {
		if (r <= y&&y <= H - r) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
N = int(input())
A = list(map(int, input().split()))
L, R, sumL_R = 0, N - 1, A[0] - A[N - 1]

while R - L > 1:
    if sumL_R < 0:
        L += 1
        sumL_R += A[L]
    else:
        R -= 1
        sumL_R -= A[R]
print(abs(sumL_R))


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

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

int main() {
	int x, y;
	cin >> x >> y;
	cout << gcd(x, y) << endl;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=1E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
int dp[1005][1005];
char m[1005][1005];
void solve(){
    int h,w;
    cin>>h>>w;
    rep1(i,h) cin>>(m[i]+1);
    dp[1][1]=1;
    rep1(i,h){
        rep1(j,w) if(m[i][j]!='#'){
            dp[i][j]+=dp[i-1][j]+dp[i][j-1];
            if(dp[i][j]>=mod) dp[i][j]-=mod;
        }
    }
    cout<<dp[h][w]<<"\n";
}
int main(){
    IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 8456
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int n = Integer.valueOf(sc.nextLine());
        final int a = Integer.valueOf(sc.nextLine());
        if(n%500 <= a) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        sc.close();
    }       
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// #define debug(a) cout << "["; rep(i,a.size()) cout << a[i] << ", "; cout<<"]"<< endl;

const ll mod = 1000000007;

int main() {
    int h,w,k; cin >> h >> w >> k;
    vector<string> field(h);
    rep(i,h) cin >> field.at(i);
    ll ans = 0;
    rep(i, pow(2, (float)h)){
       bitset<6> hbs(i);
       rep(j,pow(2, (float)w)){
           bitset<6> wbs(j);
           int blackcnt = 0;
           rep(hk, h){
               rep(wk, w){
                   if(field.at(hk).at(wk) == '#'){
                       if(!hbs.test(hk) && !wbs.test(wk)){
                           blackcnt++;
                       }
                   }
               }
           }
           if(blackcnt == k) ans ++;
       }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    char X, Y;
    cin >> X >> Y;
    if (X < Y) {
        cout << "<";
    } else if (X == Y) {
        cout << "=";
    } else {
        cout << ">";
    }
}


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

int main(){
  string s;
  cin >> s;
  int a = 0;
  int ans = 0;
  for (int i = 0; i < s.size(); i++){
    if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T'){
      a ++;
    }
    else{
      ans = max(ans, a);
      a = 0;
    }
  }
  ans = max(ans, a);
  cout << ans << endl;
}

Measured memory_bytes: 256