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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

struct UF {

  vector<int> parent_, rank_;

  UF(int N) : parent_(N + 5), rank_(N + 5, 1) {
    for (int i = 0; i < N + 5; ++i) {
      parent_[i] = i;
    }
  }

  int find_set(int x) {
    if (parent_[x] != x) {
      parent_[x] = find_set(parent_[x]);
    }
    return parent_[x];
  }

  void unite(int x, int y) {
    int px = find_set(x), py = find_set(y);
    if (px == py) { return; }
    if (rank_[px] > rank_[py]) {
      parent_[py] = px;
    }
    else {
      parent_[px] = py;
      if (rank_[px] == rank_[py]) { ++rank_[py]; }
    }
  }

  bool is_connected(int x, int y) {
    return find_set(x) == find_set(y);
  }
};

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<int> P(N + 5);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &P[i]);
  }

  UF uf(N + 5);
  for (int i = 0; i < M; ++i) {
    int x, y; scanf("%d %d", &x, &y);
    uf.unite(x, y);
  }

  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (uf.is_connected(i, P[i])) { ++ans; }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int A[500001];
int cnt = 0;

void merge(int left, int mid, int right) {
    vector<int> v1;

    cnt += right - left + 1;
    int p1 = left;
    int p2 = mid + 1;

    while (p1 <= mid && p2 <= right) {
        if (A[p1] < A[p2]) {
            v1.push_back(A[p1]);
            p1++;
        } else {
            v1.push_back(A[p2]);
            p2++;
        }
    }

    while (p1 <= mid) {
        v1.push_back(A[p1]);
        p1++;
    }

    while (p2 <= right) {
        v1.push_back(A[p2]);
        p2++;
    }

    for (int i = 0; i < v1.size(); ++i) {
        A[left + i] = v1[i];
    }
}

void mergeSort(int left, int right) {
    if (left < right) {
        int mid = left + ((right - left) >> 1);
        mergeSort(left, mid);
        mergeSort(mid + 1, right);
        merge(left, mid, right);
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    mergeSort(0, n - 1);

    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            cout << A[i];
        } else {
            cout << " " << A[i];
        }
    }
    cout << endl;
    cout << cnt << endl;
}



Measured memory_bytes: 7812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());

		int h = num / 3600;
		num = num - h * 3600; // 残りの秒数

		int m = num / 60;
		int s = num - m * 60; // 残りの秒数

		System.out.println(h + ":" + m + ":" + s);

	}

}

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

using namespace std;

typedef long long ll;

const int N = 2e5 + 10;

int n, a[N];
int bitCnt[25];
ll ans;

void include(int at) {
	for (int i = 0; i < 24; i++) bitCnt[i] += ((a[at] & (1 << i)) > 0);

	return;
}
void remove(int at) {
	for (int i = 0; i < 24; i++) bitCnt[i] -= ((a[at] & (1 << i)) > 0);

	return;
}
bool check() {
	return *max_element(bitCnt, bitCnt + 25) <= 1;
}

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	int r = 0;
	for (int at = 1; at <= n; at++) {
		while (check() && (r <= n)) {
			r++;
			include(r);
		}
		ans += r - at;
		remove(at);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  int sum = 0;
  for(int i=0;i<N;i++){
    if(i < K) sum += X;
    else sum += Y;
  }
  cout<<sum<<endl;
  
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    vector<ll> A(5);
    rep(i, 5) cin >> A[i];
    rep(i, 5) {
        if (A[i] == 0) {
            cout << i + 1 << '\n';
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

const int inf = 2e9;

typedef long long ll;

int n, x;
int w[100];
int v[100];
int dp[2][101][301];

int main(){
    cin >> n >> x;
    rep(i, n){
        cin >> w[i] >> v[i];
    }

    for(int k = 1; k <= 300; ++k){
        dp[0][0][k] = -inf;
    }  
    for(int i = 1; i <= n; ++i){
        int d = w[i - 1] - w[0];
        rep(j, i + 1){
            rep(k, 301){
                int a = dp[i - 1 & 1][j][k];
                int b = -inf;
                if(j && k >= d && ll(j) * w[0] + k <= x){
                   b = dp[i - 1 & 1][j - 1][k - d] + v[i - 1];
                }
                dp[i & 1][j][k] = max(a, b);
            }
        }
    }
    int ans = 0;
    rep(j, n + 1){
        rep(k, 301){
            ans = max(dp[n & 1][j][k], ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*
fun main(args: Array<String>) {

    val N = readLine()!!.split(" ").map{it.toInt()}
    val S = readLine()!!
    var ans = 0
    for (c in S) {
        if (c == 'R') ans++
        if (c == 'B') ans--
    }

    println(if(ans>0) "Yes" else "No")
}


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

const int N = (int) 2e6 + 5 ;
const int inf = (int) 2e9 ;

vector< int > adj[N] ;
int n , m ;
int vis[N] , arr[N] , ans = 0 ;

void dfs( int u , int c ) {
    vis[u] = c ;
    for( int v : adj[u] ) {
        if( vis[v] == 0 ) {
            dfs(v , c) ;
        }
    }
}

int main(){
//    freopen("in.txt" , "r" , stdin ) ;

    memset( vis , 0 , sizeof(vis) ) ;

    scanf("%d %d" , &n , &m ) ;
    for( int i = 1 ; i <= n ; i++ ) scanf("%d" , &arr[i] ) ;

    for( int i = 1 ; i <= m ; i++ ) {
        int u , v ; scanf("%d %d" , &u , &v ) ;
        adj[u].push_back(v) ;
        adj[v].push_back(u) ;
    }
    int c = 0 ;
    for( int i = 1 ; i <= n ; i++ ) {
        if( vis[i] == 0 ) {
            c += 1 ;
            dfs(i , c) ;
        }
    }
    for( int i = 1 ; i <= n ; i++ ) {
        ans += (vis[i] == vis[arr[i]]) ;
    }
    printf("%d\n" , ans ) ;
    return 0 ;
}


Measured memory_bytes: 62208
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<cstring>
#include<string>
#include<map>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<queue>
#include<sstream>
#include<climits>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int m,d;
	cin>>m>>d;
	int ans=0;
	for(int i=2;i<d/10+1;i++){
		for(int j=2;j<10;j++){
			if(i*10+j>d){
				break;
			}
			else if(i*j>m){
				break;
			}
			else{
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}
 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

string b;
int solve(string a, int d){
    if(d==a.size()) return 0;
    while(d<a.size() and a[d]==b[d])d++;
    if(d==a.size()) return 0;
    
    int need=10, r=b[d]-a[d];
    range(i,d,a.size()){
        a[i]=(a[i]-'0'+r+10)%10+'0';
        need=min(need,solve(a,d+1));
    }
    return need+1;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	while(cin>>n,n){
		string a;
		cin>>a>>b;
		cout<<solve(a,0)<<endl;
	}
	return 0;
}



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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;

    if(n%2 == 0)
    {
        cout << n << endl;
    }
    else
    {
        cout << n * 2 << endl;
    }
}

Measured memory_bytes: 256
// AOJ DPL_2_B Chinese Postman Problem
// 2018.5.12 bal4u
  
#include <stdio.h>
#include <string.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
  
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF  0x10101010

int V;
int dist[17][17];
int hi[17], to[17][1005], d[17][1005]; 
int dp[1<<17];

int chinesePostman(int sum)
{
	int i, j, k, S, t, s, lim;
	int odd[17], sz;

	sz = 0;
	for (i = 0; i < V; i++) {
		if (hi[i] & 1) odd[sz++] = i;
	}

	for (k = 0; k < V; k++) {
		for (i = 0; i < V; i++) if (dist[i][k] < INF) {
			for (j = 0; j < V; ++j) if (dist[k][j] < INF) {
				t = dist[i][k] + dist[k][j];
				if (t < dist[i][j]) dist[i][j] = t;
			}
		}
	}

	memset(dp, INF, sizeof(dp));
	dp[0] = 0, lim = (1<<sz)-1;
	for (S = 0; S <= lim; S++) {
		for (i = 0; i < sz; i++) if ((~S >> i) & 1) {
			for (j = 0; j < i; j++) if ((~S >> j) & 1) {
				t = dp[S] + dist[odd[i]][odd[j]];
				s = S | (1<<i) | (1<<j);
				if (t < dp[s]) dp[s] = t;
			}
		}
	}
	return sum + dp[lim];
}
 
int h[1402][1402];
char map[1402][1402];
 
int main()
{
	int k, E, s, t, a, sum;
 
	memset(dist, INF, sizeof(dist));
	V = in(), E = in();
	sum = 0;
	while (E--) {
		s = in(), t = in(), a = in();
		sum += a;
		if (a < dist[s][t]) dist[s][t] = dist[t][s] = a;
		k = hi[s]++, to[s][k] = t, d[s][k] = a;
		k = hi[t]++, to[t][k] = s, d[t][k] = a;
	}
	printf("%d\n", chinesePostman(sum));
	return 0;
}



Measured memory_bytes: 2420
//abc090_c.cpp
//Sun Mar 11 20:55:02 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

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

	long ans = 0;

	if (n>=2 && m >=2){
		ans = (n-2) * (m-2);
	}else if (n==1 && m>=2){
		ans = m-2;
	}else if (n==1 && m==1){
		ans = 1;
	}else {
		ans = n-2;
	}

	cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    int a[N];
    for (int i = 0; i < N ; ++i) cin >> a[i];

    int sum = 0;
    for (int i = 0; i < N ; ++i) sum += a[i];

    cout << sum - N << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ull, ull> P; //ペア　タイプでふ
constexpr ll bigNum = 1000000007;

int main(void)
{
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    //ここから本体
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a * b, c);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>

#define rep(i,n)	for(int i = 0;i < n;i++)
#define rep2(i,n)	for(int i = 1;i <= n;i++)
#define each(i,x)	for(auto & i : x)

using namespace std;

struct edge
{
	edge(int _s,int _t,int _cost)
	{
		s = _s;t = _t;cost = _cost;
	}
	int s;
	int t;
	int cost;
};

bool operator<(const edge & x,const edge & y)
{
	return x.cost < y.cost;
}

int uf_f(vector<int> & t,int i)
{
	if(t[i] != i)
		t[i] = uf_f(t,t[i]);
	return t[i];
}

void uf_u(vector<int> & t,int i,int j)
{
	int p1 = uf_f(t,i);
	int p2 = uf_f(t,j);
	t[i] = t[p1] = t[p2];
}

int main()
{
	int n,m;
	cin >> n;
	while(n)
	{
		cin >> m;
		vector<edge> eary;
		rep(i,m)
		{
			int a,b,d;
			//cin >> a >> b >> d;
			string s;
			cin >> s;
			rep(j,s.size())
			{
				if(s[j] == ',')
					s[j] = ' ';
			}
			stringstream ss;
			ss << s;
			ss >> a >> b >> d;
			eary.push_back(edge(a,b,d));
		}
		sort(eary.begin(),eary.end());
		vector<int> uft(n);
		rep(i,n)
		{
			uft[i] = i;
		}
		int j = 0;
		int sd = 0;
		rep(i,eary.size())
		{
			int a = eary[i].s;
			int b = eary[i].t;
			int d = eary[i].cost;
			if(uf_f(uft,a) != uf_f(uft,b))
			{
				j++;
				uf_u(uft,a,b);
				sd += d/100-1;
			}
			if(j == n-1)
				break;
		}
		cout << sd << endl;
		cin >> n;
	}
	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGoldenCoins solver = new BGoldenCoins();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGoldenCoins {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            int r = x / 500;
            long sum = r * 1000;
            int k = x - (r * 500);
            int m = k / 5;
            long u = m * 5;
            out.println(sum + u);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 22868
int main(){
int S, h, m, s;
scanf("%d", &S);
if(S >= 0 && S <= 86400){
h=S/3600;
m=(S-h*3600)/60;
s=S-h*3600-m*60;
printf("%d:%d:%d\n", h, m, s);}
return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

import static java.lang.Math.max;
import static java.lang.Math.min;


public class Main{

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        boolean[] dp = new boolean[k+1]; // true表示dp[i]剩余i石头且现在移动的人赢了
        for (int i = 1; i <= k; i++) {
            for (int j = 0; j < n; j++) {
                if(i-arr[j] >=0&&!dp[i-arr[j]]) {
                    dp[i]=true;
                }
            }
        }
        System.out.println(dp[k] == true?"First":"Second");



    }



}

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

using namespace std;

/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)  //a~(b - 1)まで
#define print(i) cout << i << endl //気持ち分Pythonてきな
#define all(i) (i).begin(),(i).end() //全選択(sortとか)
#define mp make_pair //mp(OO, OO)とか:::pintとか

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/

int main(void)
{
  string w; cin >> w;
  bool a = true;
  int ws = w.size();
  int cnt = 0;
  
  FOR(i, 0, ws){
    FOR(j, 0, ws){
      if (w[i] == w[j]) cnt++;
    }
    if (cnt % 2 == 0) a = true;
    else {
      a = false;
      cout << "No" << endl;
      break;
    }
  }
  if (a == true) cout << "Yes" << endl;

  return 0;
}


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

int main() {
  int n, d, y;
  int dp[31] = {0};
  dp[0] = 1;
  for (int i=1; i<=30; i++) {
    for (int j=0; j<3; j++) {
      if (i>j) dp[i] += dp[i-j-1];
    }
  }
  while (1) {
    cin >> n;
    if (!n) break;
    d = (dp[n] + 9) / 10;
    y = (d + 364) / 365;
    cout << y << endl;
  }
  return 0;
}

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

int main() {
	string s,t;
    string ans = "No";
    cin >> s;
    cin >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t){
      ans = "Yes";
    }
    cout << ans << endl;
}

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

using namespace std;

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

    int n = s.size();

    if(s[0] == s[n-1])
    {
        if(n%2 == 0)
            cout << "First" << endl;
        else
            cout << "Second" << endl;
    }
    else
    {
        if(n%2 == 0)
            cout << "Second" << endl;
        else
            cout << "First" << endl;
    }
}

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

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

constexpr int MAX_N = 1e5+9;
constexpr int INF = 1e9+9;

int dp[MAX_N+1];

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

  fill_n(dp, N+1, INF);
  dp[0] = 0;

  for (int i{}; i < N; ++i) {
    chmin(dp[i+1], dp[i] + 1);
    for (int j{6}; i + j <= N; j*= 6)
      chmin(dp[i+j], dp[i] + 1);
    for (int j{9}; i + j <= N; j*= 9)
      chmin(dp[i+j], dp[i] + 1);
  }

  cout << dp[N] << endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
int main(){
  int n,b[100],a[100];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&b[i]);
    if(b[i]>=i+2){
      printf("-1");
      return 0;
    }
  }
  //b[i]==iなる最も大きいiを選んで取り除く
  //という操作で選んだ数列のreverse
  for(int ia=n-1;ia>=0;ia--){
    int ib=ia;
    while(b[ib]<ib+1)ib--;
    a[ia]=b[ib];
    while(ib<ia){
      b[ib]=b[ib+1];
      ib++;
    }
  }
  for(int i=0;i<n;i++)printf("%d\n",a[i]);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};


int main() {
    int a, b, c; cin >> a >> b >> c;
    for(int i = 1; i <= b; i++){
        if((a * i) % b == c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
import collections
N=int(input())
xy=[tuple(map(int,input().split())) for i in range(N)]
table=collections.defaultdict(int)

for x,y in xy:
  for x2,y2 in xy:
    if x==x2 and y==y2:
      continue
    else:
      table[(x-x2,y-y2)]+=1
ans=0
for x in table:
  ans=max(ans,table[x])
print(N-ans)

Measured memory_bytes: 3828
#include<bits/stdc++.h>
    using namespace std;
    
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
    #define int long long 
    #define double long double
    
    #define all(a)      (a).begin(),(a).end()
    #define sz(x)       (int)x.size()
    
    #define ff first
    #define ss second
    #define mp make_pair
         
    #define pb push_back
    #define endl "\n" 
         
    #define f(i,l,r) for(int i=l;i<=r;i++)
    #define rf(i,r,l) for(int i=r;i>=l;i--)    

    #define bp __builtin_popcountll
    #define inf 1e18
    
    const int N=1e5+5; 
    const int MOD=1e9+7;
    void solve()
    {
        int n;
        cin>>n;
        bool flag=0;
        while(n>0)
        {
        	int x=n%10;
        	if(x==7)
        	flag=1;
        	n/=10;
        }
        if(flag)
        cout<<"Yes";
        else
        cout<<"No";
    }
    
    signed main()  
    {
        FAST
        int t=1;
        // cin>>t;
        while(t--)
        {
            solve();
        }
    }



Measured memory_bytes: 3636
#include <stdio.h>
int main(void){
    double a, b, c, d, e, f, x, y;
    while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF) {
        y = (d*c-a*f) / (d*b-a*e);
        x = (c-y*b) / a;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}



Measured memory_bytes: 2048
using System;
using System.Linq;
using static System.Console;

namespace b {

static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }
}

class Program {
   static bool isATCG(char c) {
      return c == 'A' || c == 'T' || c == 'C' || c == 'G';
   }

   public static void Main(string[] args) {
      var s = ReadLine();

      var count = 0;
      var prevcount = 0;
      var flag1 = false;
      var flag2 = false;
      var flag3 = false;
      for(int i = 0; i < s.Length; i++) {
         flag1 = isATCG(s[i]);
         if (flag1 == true && flag2 == false) {
            // 立ち上がり
            flag3 = true;

         }
         else if (flag1 == false && flag2 == true) {
            // 立ち下がり
            flag3 = false;
            if (prevcount < count) prevcount = count;
            count = 0;
         }

         if (flag3) count++;

         if (flag3 == true && i == s.Length - 1) {
            if (prevcount < count) prevcount = count;
         }

         flag2 = flag1;
      }

      WriteLine(prevcount);
   }
}

}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    string S[N]; rep(i, N) cin >> S[i];
    rep(i, N){
        sort(S[i].begin(), S[i].end());
    }
    sort(S, S+N);
    ll ans = 0;
    ll right = 0;
    for(ll left = 0; left < N; left++){
        string aim = S[left];
        while(right+1 < N && aim == S[right+1]) right++;
        ans += (right-left)*(right-left+1)/2;

        if(right == left) right++;
        else{
            left = right;
            right++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
import math
a,b,x = map(int,input().split())
y = 2 * x /(a * b)
siter = math.atan(2 * x / (a * b * b))
ans = 90 - math.degrees(siter)
if y >= a:
    y = (2 * x / a ** 2) - b
    ans = math.degrees(math.atan(2 * (a * a * b - x) / a ** 3))

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
typedef long long ll;
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=2e5+10,mod=1e9+7;
inline void add(int &x,int y){
	x+=y;
	x=(x>=mod?x-mod:x);
}
int dp[maxn];
int main(){
	int n=read();
	dp[0]=1;
	int lst=0;
	REP(i,1,n){
		int x=read();
		if(x==lst) continue;
		int u=dp[0],v=dp[x];
		add(dp[0],v),add(dp[x],u);
		lst=x;
	}
	printf("%d\n",dp[0]);
	return 0;
}

Measured memory_bytes: 1024
x = int(input())
if x in range(400,600):
    print("8")
elif x in range(600,800):
    print("7")
elif x in range(800,1000):
    print("6")
elif x in range(1000,1200):
    print("5")
elif x in range(1200,1400):
    print("4")
elif x in range(1400,1600):
    print("3")
elif x in range(1600,1800):
    print("2")
elif x in range(1800,2000):
    print("1")

Measured memory_bytes: 9200
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;

const ll MOD_CONST = 1000000007;



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

	int ans = 0;
	
	
	for (int i = 0; i < n; i++) {
		vector<int> z(n);
		z[i] = n - i;
		int j = i + 1, k = 0;
		while (j < n) {
			while (j + k < n && s[k+i] == s[j + k]) {
				k++;
			}
			z[j] = k;
			if (k == 0) {
				j++;
				continue;
			}

			int l = 1;
			while (j + l < n && l + z[l+i] < k) {
				z[j + l] = z[l+i];
				l++;
			}
			j += l;
			k -= l;
		}

		for (int l = i; l < n; l++) {
			int a = min(l - i, z[l]);
			ans = max(ans, a);
			//cout << a << " ";
		}
		//cout << endl;
	}
	cout << ans << endl;
}  



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <sstream>

#include <array>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>

#include <algorithm>
#include <numeric>

#include <cstdint>
#include <cctype>
#include <cmath>
#include <cassert>
#include <ctime>
#include <chrono>
#include <climits>
#include <fstream>
#include <ios>

#include <iterator>
#include <utility>
#include <complex>
#include <memory>


using namespace std;

//#define MY_DEBUG

#define DESYNC_IO


#ifdef MY_DEBUG
#define DEBUG_STDERR(x) cerr << x << endl;
#else
#define DEBUG_STDERR(x)
#endif // MY_DEBUG

void Solve() {
    string s;
    cin >> s;
    if (s.length() == 2) {
        cout << s;
    } else {
        reverse(begin(s), end(s));
        cout << s;
    }
}

void Run() {
#ifdef MY_DEBUG
    chrono::high_resolution_clock::time_point start{ chrono::high_resolution_clock::now() };
#endif // MY_DEBUG

#ifdef DESYNC_IO
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif // DESYNC_IO

#ifdef MY_DEBUG
    ifstream input{ "input.txt" };
    cin.rdbuf(input.rdbuf());
#endif // MY_DEBUG

    Solve();

#ifdef MY_DEBUG
    auto dt{ std::chrono::high_resolution_clock::now() - start };
    auto dt_millisec{ std::chrono::duration_cast<std::chrono::milliseconds>(dt) };
#endif // MY_DEBUG
    DEBUG_STDERR("\ntime spent: " << dt_millisec.count() << " miilliseconds");
}

int main() {
    Run();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long a,b,c;
int main()
{
    cin>>a>>b>>c;
    if(a== b && a==c)
    {
        cout<<"No\n";
        return 0;
    }

    if(a==b && a!=c)
    {
        cout<<"Yes\n";
        return 0;
    }

    if(a==c && a!=b)
    {
        cout<<"Yes\n";
        return 0;
    }

    if(b==c && a!=b)
    {
        cout<<"Yes\n";
        return 0;
    }
    cout<<"No\n";
    return 0;
}


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

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 10;
int a[maxn], dp[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 2; i <= n; i++){
		dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
		if (i > 2)
			dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n] << '\n';
}


Measured memory_bytes: 1024
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local K, N = read.nn()
local A = read.N(N)
A[N+1] = A[1] + K
local ans = 10^7
for i=1,N do
    local ed = i
    local st = i+1
    local d = K - (A[st] - A[ed])
    ans = math.min(ans, d)
end
print(ans)

Measured memory_bytes: 19704
// aribon2-2_g
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define ALL(x) x.begin(), x.end()
#define COUT(x) cout << x << endl
#define COUT_2DARR(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }

struct PreMain {PreMain(){std::cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


int main() {
#ifdef LOCAL
    std::ifstream in("../arg.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

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

    ull a = S.size(), b = T.size();
    REP_REV(i, a - b + 1){
        bool flag = true;
        REP(j, b){
            if (S[i+j] != '?' && S[i+j] != T[j]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            REP(j, b) S[i+j] = T[j];
            REP(j, a) { if (S[j] == '?') S[j] = 'a';}
            COUT(S);
            return 0;
        }
    }

    COUT("UNRESTORABLE");

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
//#define fi first
//#define se second
//#define P pair<int,int>
//#define PP pair<int,pair<int,int> >
//#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 105; 
int v[N], ti[N];

int main() {
	int n = read(), mx = 0, mn = n;
	rep(i,1,n) { 
		v[i] = read();
		ti[v[i]]++;
		
		mx = max(v[i],mx);
		mn = min(v[i],mn);
	}
	
	if( n == 2 ) return puts("Possible"), 0;
	
	if( mx == 1 && mn < (mx + 1) / 2 || ti[mx] < 2 ) return puts("Impossible"), 0;
	if( mx & 1 ) { 
		if( ti[(mx+1)>>1] != 2 ) return puts("Impossible"), 0;
		rep(i,((mx+3)>>1),mx) if( ti[i] < 2 ) return puts("Impossible"), 0;
	} else { 
		if( ti[mx>>1] != 1 ) return puts("Impossible"), 0;
		rep(i,(mx>>1)+1,mx) if( ti[i] < 2 ) return puts("Impossible"), 0;
	}
	puts("Possible");
	return 0; 
}

Measured memory_bytes: 256
[D,G],*li = [list(map(int,i.split())) for i in open(0)]

ans = float('inf')

def dfs(i,ten,num,p):
    global ans
    if i==D:
        if ten >= G:
            ans = min(ans,num)
        else:
            for q in p:
                for r in range(li[q][0]):
                    ten += (q+1)*100
                    num += 1
                    if r==li[q][0]:
                        ten += li[q][1]
                    if ten >= G:
                        ans = min(ans,num)
                        break
                else:continue
                break
    else:
        dfs(i+1,ten+(i+1)*100*li[i][0]+li[i][1],num+li[i][0],p)
        dfs(i+1,ten,num,[i]+p)
dfs(0,0,0,[])
print(ans)

Measured memory_bytes: 9180
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int>B(M);
	rep(i, M) {
		cin >> B[i];
	}
	vector<vector<int>>A(N, vector<int>(M));
	rep(i, N) {
		rep(j, M) {
			cin >> A[i][j];
		}
	}
	int cnt = 0;
	int sum = 0;
	rep(i, N) {
		rep(j, M) {
			sum += A[i][j] * B[j];
		}
		if (sum+C>0) {
			cnt++;
		}
		sum = 0;
	}
	cout << cnt << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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 GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 1010;

int main()
{
	string s;
	int a, b;
	cin >> s;

	a = (s[0] - '0') * 10 + s[1] - '0';
	b = (s[2] - '0') * 10 + s[3] - '0';

	if (1 <= a && a <= 12 && 1 <= b && b <= 12)
	{
		cout << "AMBIGUOUS" << endl;
	}
	else if (1 <= a && a <= 12)
	{
		cout << "MMYY" << endl;
	}
	else if (1 <= b && b <= 12)
	{
		cout << "YYMM" << endl;
	}
	else
	{
		cout << "NA" << endl;
	}
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll ai;
        cin >> ai;
        ans = __gcd(ans, ai);
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  ll n,k;cin>>n>>k;
  ll ans=1;
  ans*=k;
  ans*=pow(k-1,n-1);
  cout<<ans<<endl;
    return 0;
}

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

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

using namespace std;

typedef vector< vector<int> > graph;

// G を連結成分に分解する
vector<graph> decomp(const graph &G){
	int n=G.size();
	vector<graph> cc;
	map<int,int> f; // G における頂点番号 -> 連結成分の番号
	map<int,int> g; // G における頂点番号 -> 連結成分における頂点番号

	int c_id=0;
	vector<bool> vis(n);
	rep(u,n) if(!vis[u]) {
		vis[u]=true;

		vector<int> tmp; // 今調べている連結成分
		queue<int> Q; Q.push(u);
		while(!Q.empty()){
			int v=Q.front(); Q.pop();
			tmp.push_back(v);
			rep(i,G[v].size()){
				int w=G[v][i];
				if(!vis[w]) vis[w]=true, Q.push(w);
			}
		}

		cc.push_back(graph(tmp.size()));
		rep(i,tmp.size()){
			f[tmp[i]]=c_id;
			g[tmp[i]]=i;
		}
		c_id++;
	}

	rep(u,n) rep(i,G[u].size()) {
		int v=G[u][i];
		cc[f[u]][g[u]].push_back(g[v]);
	}

	return cc;
}

bool is_bipartite(const graph &G,int &L_res,int &R_res){
	int n=G.size();
	int L=0,R=0;
	vector<int> color(n,-1);

	rep(u,n) if(color[u]==-1) {
		color[u]=2*(L++);

		queue<int> Q; Q.push(u);
		while(!Q.empty()){
			int v=Q.front(); Q.pop();

			rep(i,G[v].size()){
				int w=G[v][i];
				if(color[w]%2==color[v]%2) return false;
				if(color[w]==-1){
					if(color[v]%2==0) color[w]=2*(R++)+1;
					else              color[w]=2*(L++);
					Q.push(w);
				}
			}
		}
	}

	L_res=L;
	R_res=R;
	return true;
}

vector<int> unify_ones(const vector<int> &a){
	vector<int> res;
	int one=0;
	rep(i,a.size()){
		if(a[i]==1) one++;
		else        res.push_back(a[i]);
	}

	int two=1;
	while(one>0){
		res.push_back(min(two,one));
		one-=min(two,one);
		two<<=1;
	}
	return res;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	graph G(n);
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	vector<graph> cc=decomp(G);

	vector<int> L(cc.size()),R(cc.size()); // 二部グラフの左右の頂点数
	rep(i,cc.size()){
		if(!is_bipartite(cc[i],L[i],R[i])) return puts("-1"),0;
		if(L[i]>R[i]) swap(L[i],R[i]);
	}

	int L_sum=0;
	vector<int> add(cc.size());
	rep(i,cc.size()){
		L_sum+=L[i];
		add[i]=R[i]-L[i];
	}

	// add[i]==1 がたくさんあると部分和問題を解くのに時間がかかりすぎるので, 適当にまとめる ( 個数制約があるナップザックと同じ tips )
	add=unify_ones(add);

	// knapsack DP
	int N=L_sum; // 最適な左の頂点数 ( n/2 以下で最大になるよう振り分ける )
	vector<bool> dp(n+1); dp[0]=true;
	rep(i,add.size()){
		for(int j=n/2-L_sum-add[i];j>=0;j--){
			if(dp[j]){
				dp[j+add[i]]=true;
				if(abs(L_sum+j+add[i]-n/2.0)<abs(N-n/2.0)) N=L_sum+j+add[i];
			}
		}
	}

	printf("%u\n",N*(n-N)-m);

	return 0;
}

Measured memory_bytes: 22516
#include <bits/stdc++.h>
#include <algorithm>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long 
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define endl "\n"
using namespace std;

ll gcd(ll a, ll b){
    return __gcd(a,b);
}

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

bool isPrime(ll n){
    if(n <= 1) return false;
    for(ll i=2; i<=sqrt(n); i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}

void solve(){
   ll l,r,d,ans=0;
   cin >> l >> r >> d;
   for(ll i=l; i<=r; i++){
       if(i%d==0) ans++;
   }
   cout << ans << endl;
}

int main() {
    fast;
    solve();
	//ll t; cin >> t; while(t--){ solve(); }
	return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
int n;
int main()
{
  scanf("%d",&n);
  for(int i=n;i<=999;i++)
    if((i/100) == (i/10%10) && (i/10%10) == i%10)
    {
      printf("%d\n",i);
      break;
    }
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n); REP(i, n) cin >> a[i];
  int sum = accumulate(ALL(a), 0);
  sort(ALL(a), greater<int>());
  REP(i, m) {
    if (a[i] * 4 * m < sum) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



  //二分探索(最小値を出す問題は疑う)

// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < n; ++i){
// 		res += max(0ll, a[i]-x/f[i]);
//     }
//     return res <= k;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }



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

double S1 = a * b;
double S2 = x / a;
double ans;
double rad;
if(S2 >= S1 / 2){
double h = 2 * (S1 - S2) / a;
rad = atan2(h, a);
}else if(S2 < S1 / 2){
double w = (2 * S2) / b;
rad = atan2(b , w);
}

ans = rad / (2 * PI) * 360;

cout << fixed << setprecision(10) << ans << endl;
}

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

//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  int n;
  F f;
  G g;
  T d1;
  E d0;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T d1,
	      vector<T> v=vector<T>()):
    f(f),g(g),d1(d1){
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=d1,vr=d1;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }
  
};
//END CUT HERE

int main(){
    int64_t n, q;
    cin >> n >> q;
    SegmentTree<int,int> A(n,
                [](int a,int b){return min(a,b);},
                [](int a,int b){return b;},
                n - 1);
    
    SegmentTree<int,int> B(n,
            [](int a,int b){return min(a,b);},
            [](int a,int b){return b;},
            n - 1);

    int64_t ans = (n - 2) * (n - 2);
    for (int Q = 0; Q < q; Q++){
        int a, b;
        cin >> a >> b;
        auto &C = (a == 1 ? A : B);
        auto &D = (a == 1 ? B : A);
        b--;
        int d = C.query(b, n);
        ans -= d - 1;
        if (D.query(d, d + 1) > b)
            D.update(d, b);
    }

    cout << ans << endl;
}


Measured memory_bytes: 7436
import sys
from datetime import *
from time import *


day = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ]

while True:
    try:
        user_input_date = '2004/'+'/'.join(input().split())
        if user_input_date == '2004/0/0':
            break
        else:
            a = datetime.strptime(user_input_date,'%Y/%m/%d')
            print(day[a.weekday()])
    except ValueError:
        pass
else:
    sys.exit(1)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    ll n;
    cin >> n;
    if(n % 2 == 0){
        cout << n << endl;
    }
    else{
        cout << 2*n << endl;
    }
    return 0;
}

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

typedef long long ll;
#define fi first
#define se second

using namespace std;

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

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


ll X, Y;
ll t;
ll a;
ll cnt = 0;
ll w = 2;

int main(){
  
  cin>>X>>Y;
  
  if( X < Y ){
    t = X;
    X = Y;
    Y = t;
  }
  
  if( Y <= 1 && X <= 1 ) puts("Brown");
  else if( ( Y == 1 || Y == 2 ) && X == 2 ) puts("Brown");
  else{
    if( X - Y <= 1 ) puts("Brown");
    
    else{   puts("Alice");}
  }
  
  
  return 0;
}

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

const ll mod = 1e9+7;
ll fact(ll n){
    ll res = 1;
    for(int i = 2; i <= n; i++){
        res = (res * i) % mod;
    }
    return res;
}
ll binaryExpo(ll base, ll expo){
    ll res = 1;
    while(expo > 0){
        if(expo & 1){
            res = (res * base) % mod;
        }
        base = (base * base) % mod;
        expo /= 2;
    }
    return res;
}
int main() {
    string str;
    cin >> str;
    int count = 0, m=0;
    if(str == "RRR"){
        cout << 3 << "\n";
        return 0;
    }
    for(int i = 0; i < 3; i++){
        if(str[i] == 'S'){
            m = max(count,m);
            count = 0;
        }
        if(str[i] == 'R'){
            count++;
        }
    }
    cout << max(m,count) << endl;

}






Measured memory_bytes: 3592