akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  vector<tuple<long double,ll,ll>> cor(n);
  rep(i,n){
    long double x,y;
    cin >> x >> y;
    long double ang = atan2(y,x);
    cor[i] = make_tuple(ang,x,y);
  }

  sort(cor.begin(),cor.end());
  rep(i,n){
    cor.pb(make_tuple(get<0>(cor[i])+2*M_PI, get<1>(cor[i]), get<2>(cor[i])));
  }

  long double eps=1e-12;
  long double ans=0;
  rep(i,n){
    long double st = get<0>(cor[i]);
    int ed_idx = i;    
    long double x = get<1>(cor[i]);
    long double y = get<2>(cor[i]);
    while(get<0>(cor[ed_idx+1]) - st < M_PI+eps){
      ans = max(ans,sqrt(x*x+y*y));
      ed_idx++;
      x+=get<1>(cor[ed_idx]);
      y+=get<2>(cor[ed_idx]);      
    }
    //    cout << "stidx edidx len " << i << " " << ed_idx << " " << sqrt(x*x+y*y) << endl; 
    ans = max(ans,sqrt(x*x+y*y));
    
  }
  cout << fixed << setprecision(12) << ans << endl;
    
  

  return 0;
    

}


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

using namespace std;

int main() {
  long long int n, m;
  cin >> n >> m;
  multimap<long long int, long long int> mp;
  long long int sum = 0;

  for ( int i = 0; i < n; i++ ) {
    long long int a, b;
    cin >> a >> b;
    mp.insert(pair<long long int, long long int>(a, b));
  }
  for ( const auto& e : mp ) {
    if ( m >= e.second ) {
      sum += e.first * e.second;
      m -= e.second;
      if ( m == 0 ) break;
    }
    else {
      sum += e.first * m;
      break;
    }
  }
  cout << sum << endl;
  return 0;
}

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

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

    string s;
    cin >> s;
    int n = s.size();

    int k;
    cin >> k;
    string res = "";

    for(int i = 0; i < n-1; ++i){
        int now = s[i] - 'a';
        if(26 - now > k || now == 0) res += s[i];
        else{
            res += 'a';
            k -= 26 - now;
        }
    }

    int last = s.back() - 'a';
    last += k;
    last %= 26;
    res += char('a' + last);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3752
import java.util.*;
//import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;
import java.math.BigInteger;

public class Main {
	static long cnt=0;
	static BigInteger bi13 =new BigInteger("13");
	static BigInteger bi5 =new BigInteger("5");

	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		sc.close();
		int a[] = new int[s.length()];
		boolean prer = true;
		int rcnt = 1;
		int lcnt = 0;
		int p1=0;
		int p2=0;
		int aa;
		for (i = 1; i < s.length(); i++) {
			if(prer) {
				if(s.charAt(i) == 'R') {
					rcnt++;
				} else {
					prer=false;
					lcnt++;
					p1 = i-1;
					p2 = i;
				}
			} else {
				if(s.charAt(i) == 'R') {
					prer=true;
					aa = rcnt + lcnt;
					a[p1] = aa/2;
					a[p2] = aa/2;
					if(aa % 2 ==1) {
						if(rcnt % 2 ==1) {
							a[p1]++;
						} else {
							a[p2]++;
						}
					}
					rcnt=1;
					lcnt=0;
				} else {
					lcnt++;
				}
			}
		}
		aa = rcnt + lcnt;
		a[p1] = aa/2;
		a[p2] = aa/2;
		if(aa % 2 ==1) {
			if(rcnt % 2 ==1) {
				a[p1]++;
			} else {
				a[p2]++;
			}
		}
		PrintWriter out = new PrintWriter(System.out);
		for(i = 0; i < s.length(); i++) {
			out.print(a[i]);
			out.print(" ");
		}
		out.flush();
	}
}


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

int main() {
  string s;
  cin>>s;
  int a=s.at(5)-'0';
  int b=s.at(6)-'0';
  int c=s.at(8)-'0';
  int d=s.at(9)-'0';
  if(a==1)
    cout<<"TBD"<<endl;
  else if(b>4)
    cout<<"TBD"<<endl; 
  else if(b<4)
    cout<<"Heisei"<<endl;
  else if(c<3)
    cout<<"Heisei"<<endl;
  else if(d<1)
    cout<<"Heisei"<<endl;
  else 
    cout<<"TBD"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] abx = scanner.nextLine().split(" ", 3);
        int a = Integer.parseInt(abx[0]);
        int b = Integer.parseInt(abx[1]);
        int x = Integer.parseInt(abx[2]);

        if (a <= x && x <= a + b) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21844
#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>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
//typedef pair<int, int> IP;
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)
#define mp make_pair
#define P pair<int,int>

int main() {
	int INF = 100000000;
	int V;
	cin >> V;
	vector<vector<P>>G(V);
	rep(i, V) {
		int v, k;
		cin >> v >> k;
		rep(j, k) {
			int tmpv, tmpc;
			cin >> tmpv >> tmpc;
			G[i].push_back(mp(tmpv, tmpc));
		}
	}
	int start = 0;//スタート位置
	vector<int>dist(V, INF);//startからの距離を入れる配列。INF(未訪問)で初期化
	dist[start] = 0;
	priority_queue<P, vector<P>, greater<P>>que;//少ない値を優先するプライオリティキューを宣言
	que.push(mp(dist[start], start));

	while (!que.empty()) {
		P p = que.top();
		int v = p.second;
		que.pop();
		if (dist[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			P e = G[v][i];
			int u = e.first, cst = e.second;
			if (dist[u] > dist[v] + cst) {
				dist[u] = dist[v] + cst;
				que.push(mp(dist[u], u));
			}
		}
	}
	rep(i, V) {
		cout << i << ' ' << dist[i] << endl;
	}
}


Measured memory_bytes: 3124
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int DIRX[4] = {1, -1, 0, 0};
int DIRY[4] = {0, 0, 1, -1};

int main() {
	int h, w;
	int b = 0;
	char m[51][51];
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			cin >> m[j][i];
			if(m[j][i] == '#') b++;
		}
	}

	queue<pair<int, pair<int, int> > > que;
	que.push(MP(0, MP(0, 1)));

	int ans = -1;
	bool used[51][51] = {};

	while(que.size()){
		pair<int, pair<int, int> > now;
		now = que.front();
		que.pop();
		int nx = now.first;
		int ny = now.second.first;
		int nc = now.second.second;

		if(nx == w-1 && ny == h-1){
			ans = h*w - b - nc;
			break;
		}

		if(used[nx][ny]) continue;
		used[nx][ny] = true;

		for(int i = 0;i < 4;i++){
			int tx = nx + DIRX[i];
			int ty = ny + DIRY[i];
			int tc = nc + 1;
			if(tx < 0 || tx >= w || ty < 0 || ty >= h) continue;
			if(m[tx][ty] == '#') continue;
			if(used[tx][ty]) continue;
			que.push(MP(tx, MP(ty, tc)));
		}
	}


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

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Schitiz
 */
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);
        C_166 solver = new C_166();
        solver.solve(1, in, out);
        out.close();
    }

    static class C_166 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.ni();
            int k = in.ni();

            boolean[] arr = new boolean[n];
            for(int i = 0; i < k; i++) {
                int count = in.ni();
                for(int j = 0; j < count; j++) {
                    int index = in.ni();
                    arr[index - 1] = true;
                }
            }
            int count = 0;
            for(boolean b : arr) {
                if(!b) count++;
            }
            out.println(count);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if(numChars == -1) {
                throw new InputMismatchException();
            }
            if(curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch(IOException e) {
                    throw new InputMismatchException();
                }
                if(numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int ni() {
            int c = read();
            while(isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if(c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if(c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while(!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            if(filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        private static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32944
import java.util.*;
class Main
{
		public static void main(String[] args)
		{
			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			int[] param1 = new int[n];
			
			for(int i=0 ; i<n ; i++){
				
				param1[i] = sc.nextInt();
				
			}
			
			int res = 0;
			
			while(true){
			
			int sum = 0;
			
			for(int i=0 ; i<n ; i++){
			
			if(param1[i]%2==0){
				sum++;
			}else{
				System.out.println(res);
				return;
			}
			
			}
			
			if(sum==n){
				for(int i=0 ; i<n ; i++){
					param1[i]/=2;
				}
			}
			res++;
			}
		}
}

Measured memory_bytes: 21588
#include<stdio.h>
int main(){
int n,pa,pb,a,b,i;
while(1){
scanf("%d",&n);
pa=0;
pb=0;
if(n==0) return 0;
else{
for(i=0;i<n;i++){
scanf("%d %d",&a,&b);
if(a<b) pb=pb+a+b;
else if(a>b) pa=pa+a+b;
else{
pa+=a;
pb+=b;
}
}
}
printf("%d %d\n",pa,pb);
}
}

Measured memory_bytes: 600
import java.util.*;

public class Main{
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int min = 1000;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a < min) {
                min = a;
            }
            if (a > max) {
                max = a;
            }
        }
        System.out.println(max - min);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

typedef vector<double> vec;
typedef vector<vec> mat;

#define EPS (1e-9)

// ガウスの消去法で連立式をとく
vec gauss_jordan(const mat&A,const vec &b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i = 0; i < n;i++)
    for(int j=0;j<n;j++)
      B[i][j]=A[i][j];
  for(int i = 0; i < n; i++)
    B[i][n]=b[i];
  // 各変数に注目
  for(int i = 0; i < n; i++){
    // 最大の係数の絶対値をもつものをi番目に持ってくる
    int piv=-1;
    double val=-1;
    for(int j=i;j<n;j++){
      if(val<abs(B[j][i])){
	piv=j;
	val=abs(B[j][i]);
      }
    }
    // B[i][n]が0でない場合は、解は存在しない
    // 0である場合は、複数の解が存在する可能性あり
    if(piv==-1||val<EPS)return vec();
    swap(B[piv],B[i]);
    // i行目をそれぞれB[piv][i]の値で割る
    double divNum=B[i][i];
    for(int j = i; j <= n; j++)
      B[i][j]/=divNum;
    // それぞれの行から、i行目の値を引くかんじ
    for(int j = 0; j < n; j++){
      if(i==j)continue;
      double mulnum=B[j][i];
      for(int k = i; k <= n; k++)
	B[j][k]-=mulnum*B[i][k];
    }
  }
  vec res(n);
  for(int i = 0; i < n; i++)res[i]=B[i][n];
  return res;
}

const int INF=1000000000;
int n,s,g;
int qs[101];
int as[101][101];
int d[101][101];

int main(){

  while(cin>>n>>s>>g&&(n|s|g)){
    s--;g--;
    for(int i=0;i<n;i++)cin>>qs[i];
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i!=j)d[i][j]=INF;
	else d[i][j]=0;
	cin>>as[i][j];
	// ルート無し
	if(as[i][j]==0)as[i][j]=INF;
	d[i][j]=min(d[i][j],as[i][j]);
      }
    }
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	for(int k=0;k<n;k++)
	  d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
    if(d[s][g]==INF){
      cout<<"impossible"<<endl;
      continue;
    }
    mat A(n,vec(n,0));
    vec b(n,0);
    for(int i=0;i<n;i++){
      if(i==g){
	A[i][i]=1;
	continue;
      }
      if(d[i][g]==INF){
	A[i][i]=1;
	continue;
      }
      if(qs[i]){
	int cnt=0;
	int scost=0;
	// 最短距離を構成するルートのみ考慮
	for(int j=0;j<n;j++){
	  // if(d[i][j]==INF||(i==j&&as[i][j]==INF))
	  //   continue;
	  if(as[i][j]==INF)continue;
	  if(as[i][j]+d[j][g]==d[i][g]){
	    cnt++;
	    scost+=as[i][j];
	    A[i][j]=1;
	  }
	}
	if(cnt!=0)b[i]=(double)scost/cnt;
	if(cnt!=0)for(int j=0;j<n;j++)A[i][j]/=(-cnt);
	A[i][i]+=1;
      }
      else{
	int cnt=0;
	int scost=0;
	for(int j=0;j<n;j++){
	  // if(d[i][j]==INF||(i==j&&as[i][j]==INF))
	  //   continue;
	  if(as[i][j]==INF)continue;
	  cnt++;
	  scost+=as[i][j];
	  A[i][j]=1;
	}
	if(cnt!=0)b[i]=(double)scost/cnt;
	if(cnt!=0)for(int j=0;j<n;j++)A[i][j]/=(-cnt);
	A[i][i]+=1;
      }
    }
    // A[4][4]=1;
    // A[4][3]=-1;
    // b[4]=1;
    vec v=gauss_jordan(A,b);
    // for(int i=0;i<v.size();i++)
    //   cout<<v[i]<<endl;
    printf("%.10f\n",v[s]);
  }

  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s; cin >> s;

    int num=0;
    for(uint i=0; i<s.size(); ++i){
        if(s[i]=='+'){ ++num;
        }    else    { --num; }
    }
    
    cout << num << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int n; cin >> n;
  vector<ll> a(n);

  ll sum = 0ll;

  ll mc = 0, min_max = numeric_limits<int>::min(), max_min = numeric_limits<int>::max();
  REP(i, n){
    cin >> a[i];
    if(a[i] < 0){
      mc += 1;
      min_max = max(min_max, a[i]);
    } else {
      max_min = min(max_min, a[i]);
    }

    sum += max(a[i], -a[i]);
  }

  if(mc % 2){
    sum = max(sum - 2 * max_min, sum + 2 * min_max);
  }

  cout << sum << endl;
  
  return 0;
}


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

int main()
{
    size_t H, W;
    cin >> H >> W;

    vector<size_t> A(H);
    vector<size_t> B(H);
    for (size_t i = 0; i < H; i++)
    {
        cin >> A[i] >> B[i];
    }

    set<pair<size_t, size_t>> goal_start;
    multiset<int> ans;
    for (size_t i = 1; i <= W; i++)
    {
        goal_start.insert(make_pair(i, i));
        ans.insert(0);
    }

    for (size_t i = 0; i < H; i++)
    {
        size_t start = 0;
        size_t right = 0;
        for (set<pair<size_t, size_t>>::iterator itr = goal_start.lower_bound(make_pair(A[i], 0)); itr != goal_start.end() && itr->first <= B[i]; itr = goal_start.erase(itr))
        {
            size_t goal = itr->first;
            start = itr->second;

            ans.erase(ans.find(goal - start));
            right = max(right, start);
        }
        if (start > 0 && B[i] < W)
        {
            goal_start.insert(make_pair(B[i] + 1, right));
            ans.insert(B[i] + 1 - right);
        }
        if (ans.empty())
        {
            cout << -1 << endl;
        }
        else
        {
            cout << i + 1 + *ans.begin() << endl;
        }
    }
}


Measured memory_bytes: 28280
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;

const int N = 100010;

int n, m;
int a[N], s[N], p[N], fw[N * 2];

void ch(int k) {
  for (; k <= m; k += k & -k) ++fw[k];
}

int qr(int k) {
  int ret = 0;
  for (; k; k &= k - 1) ret += fw[k];
  return ret;
}

ll pred(int x) {
  for (int i = 1; i <= n; ++i)
    p[i] = p[i - 1] + (a[i] <= x ? -1 : 1);
  m = n * 2 + 1;
  // p[i] < p[j] ? -1 : 1;
  ll ret = 0;
  memset(fw, 0, sizeof(fw));
  for (int i = 0; i <= n; ++i) {
    int v = p[i] + n + 1;
    ret += 2 * qr(v) - i;
    ch(v);
  }
  return ret;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
#endif

  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  memcpy(s, a, sizeof(a));
  sort(s + 1, s + n + 1);
  for (int i = 1; i <= n; ++i)
    a[i] = lower_bound(s + 1, s + n + 1, a[i]) - s;
  int l = 1, r = n;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (pred(mid) < 0)
      r = mid;
    else
      l = mid + 1;
  }
  printf("%d\n", s[l]);

  return 0;
}


Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define MOD (1000000007ll)

int main(void){
	ll i,n,a[123456],b[123456],c[123456],x[123456],ans=0ll;
	ll *p;
	cin >> n;
	fill(x,x+123456,0);
	for(i=0ll; i<n; ++i){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=0ll; i<n; ++i){
		cin >> b[i];
	}
	sort(b,b+n);
	for(i=0ll; i<n; ++i){
		cin >> c[i];
	}
	sort(c,c+n);
	for(i=0ll; i<n; ++i){
		p = upper_bound(c,c+n,b[i]);
		x[i] = (n - (ll)(p-c));
	}
	for(i=n; i>0ll; --i){
		x[i-1] += x[i];
	}
	for(i=0ll; i<n; ++i){
		p = upper_bound(b,b+n,a[i]);
		ans += x[(int)(p-b)];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4096
import java.util.Scanner;

//Hide-and-Seek Supporting System
public class Main {

	public static class Point {
		public double x;
		public double y;
		public Point(double x_, double y_) {
			x = x_; y=y_;
		}
	}

	public static class Line {
		public Point s,t;
		public Line(Point s_, Point t_) {
			s = s_; t = t_;
		}
	}

	public static double distanceSP(Line s, Point p) {
		Point r = proj(s, p);
		if (intersectSP(s, r)) return norm(sub(r, p));
		return Math.min(norm(sub(s.s, p)), norm(sub(s.t, p)));
	}

	public static boolean intersectSP(Line s, Point p) {
		return ccw(s.s, s.t, p) == 0;
//		return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
	}

	public static int ccw(Point a, Point b, Point c) {
		Point p = sub(b, a);
		Point q = sub(c, a);
		if(extp(p, q) > EPS) return 1;		// counter clockwise
		if(extp(p, q) < -EPS)return -1;		// clockwise
		if(inp(p, q) < -EPS) return 2;		// c--a--b on line
		if(Math.abs(norm(p) - norm(q)) < EPS) return -2;	// a--b--c on line
		return 0;				// a--c--b(or a--c=b) on line
	}

	public static Point sub(Point p1, Point p2) {
		return new Point(p1.x-p2.x, p1.y-p2.y);
	}

	public static double inp(Point p1, Point p2) {
		return p1.x*p2.x + p1.y*p2.y;
	}
	public static double extp(Point p1, Point p2) {
		return p1.x*p2.y - p2.x*p1.y;
	}

	public static double norm(Point p) {
		return Math.hypot(p.x, p.y);
	}

	public static final double EPS = 1.0e-8;

	public static Point proj(Line l, Point p) {
		double t = inp(sub(p, l.s), sub(l.s, l.t)) / Math.pow(norm(sub(l.s, l.t)),2);
		Point tp = sub(l.s, l.t);
		return new Point(l.s.x + t*tp.x, l.s.y + t*tp.y);
	}

	static class C{
		public Point center;
		public double r;
		public C(Point center, double r) {
			this.center = center;
			this.r = r;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			C[] c = new C[n];
			for(int i=0;i<n;i++)c[i]=new C(new Point(sc.nextDouble(), sc.nextDouble()), sc.nextDouble());
			int m = sc.nextInt();
			while(m--!=0){
				Point u = new Point(sc.nextDouble(), sc.nextDouble());
				Point v = new Point(sc.nextDouble(), sc.nextDouble());
				Line line = new Line(u, v);
				boolean danger = true;
				for(int i=0;i<n;i++){
					double dsp = Math.max(distanceSP(line, c[i].center), distanceSP(new Line(v, u), c[i].center));
					if(dsp <= c[i].r){
						double n1 = norm(new Point(u.x-c[i].center.x, u.y-c[i].center.y));
						double n2 = norm(new Point(v.x-c[i].center.x, v.y-c[i].center.y));
						if(!(n1 <= c[i].r && n2 <= c[i].r))
							danger = false;
					}
				}
				System.out.println(danger?"Danger":"Safe");
			}
		}
	}
}

Measured memory_bytes: 45296
import java.util.*;

public class Main {
	static Scanner scan = new Scanner(System.in);
	
	public static void main(String[] args) {
		String s = scan.next();
		String t = scan.next();
		int ans = t.length();
		
		for(int i=0;i<=s.length()-t.length();i++) {
			int now_ans = t.length();
			for(int j=0;j<t.length();j++) {
				if(s.charAt(i+j) == t.charAt(j)) {
					now_ans--;
				}
			}
			ans = Math.min(ans, now_ans);
		}
		
		System.out.println(ans);
		
		
		
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 





Measured memory_bytes: 35792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        void Solve()
        {
            int[] abc = ReadsInt();

            if(abc[0] == abc[1] + abc[2] || abc[1] == abc[0] + abc[2] || abc[2] == abc[0] + abc[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        string Read()
        {
            return Console.ReadLine();
        }

        int ReadInt()
        {
            return Int32.Parse(Read());
        }

        string[] Reads()
        {
            return Read().Split();
        }

        int[] ReadsInt()
        {
            return Reads().Select(s => Int32.Parse(s)).ToArray();
        }


        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}


Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;cin>>n;
    vector<vector<P>> in(n);
    rep(i,n){
        int a;cin>>a;
        rep(j,a){
            int b,c;cin>>b>>c;b--;
            in[i].push_back(make_pair(b,c));
        }
    }
    int ans=0;
    for(int i=0;i< (1<<n);i++){
        bitset<15> bit(i);
        bool ok = true;
        rep(j,n){
            if(bit.test(j)){
                rep(k,in[j].size()){
                    if(bit.test(in[j][k].first)== in[j][k].second){
                        continue;
                    }else{
                        ok = false;
                        break;
                    }
                }
            }
            if(!ok) break;
        }
        if(ok){
            int bi = bit.count();
            ans = max(ans,bi);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct CumulativeSum{
    vector<int> data;
    CumulativeSum(int sz) : data(sz, 0) {};
    void add(int k, int x){
        data[k] += x;
    }
    void build(){
        for(int i = 1; i < data.size(); i++){
            data[i] += data[i - 1];
        }
    }
    //区間[0,k]の和
    int query(int k){
        if(k < 0) return 0;
        return (data[min(k, (int)data.size() - 1)]);
    }
    //区間[l.r)の和
    int query(int l, int r){
        return query(r - 1) - query(l - 1);
    }
};

int n, q;
vector<int> a;

bool f(int m, int x){
    bool res = true;
    int takahashi_left = n - m;
    int diff = a[takahashi_left] - x;
    if(diff < 0) return false;
    int left = lower_bound(a.begin(), a.end(), x - diff) - a.begin();
    int right = lower_bound(a.begin(), a.end(), x + diff) - a.begin();
    int num = right - left;
    // cout << m << ' ' << x << ' ' << diff << " " << left << ' ' << right << endl;
    return num >= m - 1;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    a.resize(n);
    rep(i, 0, n) cin >> a[i];
    CumulativeSum odd(n), even(n), sum(n);
    rep(i, 0, n){
        if(i % 2 == 0){
            even.add(i, a[i]);
            odd.add(i, 0);
            sum.add(i, a[i]);
        }else{
            even.add(i, 0);
            odd.add(i, a[i]);
            sum.add(i, a[i]);
        }
    }
    odd.build();
    even.build();
    sum.build();

    while(q--){
        int x;
        cin >> x;
        int ok = 1, ng = n;
        while(ng - ok > 1){
            int mid = (ng + ok) / 2;
            if(f(mid, x)) ok = mid;
            else ng = mid;
        }
        // cout << ok << " " << n - ok << " " << n - 2 * ok - 1 << endl;
        int ans = sum.query(n - ok, n);
        int idx = n - 2 * ok - 1;
        if(idx >= 0){
            if(idx % 2 == 0) ans += even.query(0, idx + 1);
            else ans += odd.query(0, idx + 1);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4992
mod = 10 ** 9 + 7

# permutation: n * (n-1) * …… * (n-k+1) (mod p)
def prm(n, k, p=10**9+7):
    res = 1
    for i in range(k):
        res = res * (n-i) % p
    return res

# combination: nPk / k! (mod p), note: p must be a prime number
def cmb(n, k, p=10**9+7):
    return prm( n, k ) * pow( prm(k, k), p-2, p ) % p

n, a, b = map(int, input().split())

#何も選ばない1通りを除く
ans = pow(2,n,mod) - 1 - cmb(n,a) - cmb(n,b)
print(ans % mod)

Measured memory_bytes: 3064
#editorial
n,q=map(int,input().split())
*qu,=[tuple(map(int, input().split())) for _ in range(q)]
w=n-2;h=n-2
wwh=[n-2]*(n-2)
hhw=[n-2]*(n-2)
b=0
for t,x in qu:
    x-=2
    if t==1:
        
        if x<w:
            b+=h
            for i in range(x,w):
                wwh[i]=h
            w=x
        else:
            b+=wwh[x]

    else:
        if x<h:
            b+=w
            for i in range(x,h):
                hhw[i]=w
            h=x
        else:
            b+=hhw[x]

ans=(n-2)*(n-2)-b
print(ans)
    


Measured memory_bytes: 109656
import itertools
N,M=map(int,input().split())
path=[list(map(int,input().split())) for _ in range(M)]
seq=list(range(2,N+1))
#print(path)
l=list(itertools.permutations(seq))
#print(l)
buf=[]
cnt=0
for i in range(len(l)):
    buf=list(l[i])
    piv1=1
    #print(buf,len(buf))
    for j in range(len(buf)):
        flag = 0
        piv2=buf[j]
        #print(i,piv1,piv2)
        for k in range(M):
            mi=min(piv1,piv2)
            ma=max(piv1,piv2)
            if (path[k][0]==mi)and(path[k][1]==ma):
                flag=1
        #input()
        if flag==0:
            break
        else:
            piv1=piv2
    if flag==1:
        cnt=cnt+1
print(cnt)





Measured memory_bytes: 47344
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,m;
map<int,int> ma;
int main(){
	cin>>m>>n;
	int a[20]={0};
	int x;
	int ans = 0;
	rep(i,m){
		rep(j,n){
			scanf("%d",&x);
			if(x==1){
				ma[i]++;
				if(ma[i]>ans){
					ans = ma[i];
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1232
#include<stdio.h> 
int main()
{
	int i, j, tmp;
	int data[10];

    for(i = 0; i < 10; i++){
		scanf("%d",&data[i]);
	}
    for(i = 0; i < 9; i++)
    {
        for(j = 0; j < 9 - i; j++)
        {
            if(data[j] < data[j+1])
            {
                tmp = data[j];
                data[j] = data[j+1];
                data[j+1] = tmp;
            }
        }
    }
    for(i=0; i < 3; i++)
        printf("%d\n",data[i]);
 
    return 0;
}

Measured memory_bytes: 600
n = int(input())
a = [int(i) for i in input().split()]
a_uni = list(set(a))
if len(a_uni) == 1:
	if a[0] == 0:
		print("Yes")
	else:
		print("No")
elif n%3 != 0:
	print("No")
elif len(a_uni) == 2:
	if a.count(0) == n/3:
		print("Yes")	
	else:
		print("No")	
elif len(a_uni) == 3:
	if a_uni[0]^a_uni[1]!=a_uni[2]:
		print("No")
	elif a.count(a_uni[0])==n/3 and a.count(a_uni[1])==n/3:
		print("Yes")
	else:
		print("No")
else:
	print("No")

Measured memory_bytes: 14836
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<bitset>
#include<vector>
using namespace std;
#define i32 int
#define i64 long long
#define db double
#define rep(i,s,n) for(i32 i=s;i<=n;i++)
#define rep_(i,n,s) for(i32 i=n;i>=s;i--)
i32 RI(){
    char ch=getchar();i32 sum=0,f=1;
    while(!isdigit(ch)){
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(isdigit(ch))sum=sum*10+ch-'0',ch=getchar();
    return f*sum;
}
i64 RL(){
    char ch=getchar();i64 sum=0;
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))sum=sum*10+ch-'0',ch=getchar();
    return sum;
}
const i32 N=5005;
const i32 mod=1e9+7;
i32 n,ans;
i32 F[N][N],A[300000],B[300000],jc[N<<2];
i32 ksm(i32 x,i32 y){
    i32 s=1;
    while(y){
        if(y&1)s=1LL*s*x%mod;
        y>>=1;
        x=1LL*x*x%mod;
    }
    return s;
}
i32 C(i32 x,i32 y){return 1LL*jc[x]*ksm(1LL*jc[x-y]*jc[y]%mod,mod-2)%mod;}
i32 get(i32 x,i32 y){return C(x+y,x);}
i32 main(){
    n=RI();
    rep(i,1,n){A[i]=RI();B[i]=RI();F[-A[i]+2001][-B[i]+2001]++;}
    jc[0]=1;rep(i,1,10000)jc[i]=1LL*jc[i-1]*i%mod;
    rep(i,1,4500){
        rep(j,1,4500){
            F[i][j]=(F[i][j]+F[i-1][j]+F[i][j-1])%mod;
        }
    }
    rep(i,1,n){
        ans=(ans+F[A[i]+2001][B[i]+2001])%mod;
        ans=(ans-get(A[i]<<1,B[i]<<1)+mod)%mod;
    }
    ans=1LL*ans*ksm(2,mod-2)%mod;
    printf("%d",ans);
}   

Measured memory_bytes: 91904
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin>>N;
  if(N==1){
      cout<<"Hello World"<<endl;
  }
  else{
      int A,B;
      cin>>A>>B;
      cout<<A+B<<endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cout << #x << " = " << x << endl;
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    solve();
    return 0;
}

const int MAXN = 1e6 + 10;

void solve() {
    int n;
    cin >> n;   
    vec<int> a(n);
    cin >> a;
    int G = a[0];
    for (int i = 1; i < n; ++i) {
        G = __gcd(G, a[i]);
    }   

    if (G != 1) {
        cout << "not coprime" << endl;
        return;
    }

    vec<int> min_p(MAXN);
    vec<int> p;
    for (int i = 2; i < MAXN; ++i) {
        if (min_p[i] == 0) {
            min_p[i] = i;
            p.pb(i);
        }
        for (int j = 0; j < sz(p) && p[j] * i < MAXN && p[j] <= min_p[i]; ++j) {
            min_p[i * p[j]] = p[j];
        }
    }

    vec<vec<int>> nums(MAXN);
    for (auto it : a) {
        set<int> se;
        int x = it;
        while (x > 1) {
            se.insert(min_p[x]);
            x /= min_p[x];
        }
        for (auto el : se) {
            nums[el].pb(it);
        }
    }

    bool ok = true;
    for (int i = 2; i < MAXN; ++i) {    
        if (sz(nums[i]) > 1) {
            ok = false;
            break;
        }
    }

    if (!ok) {
        cout << "setwise coprime" << endl;
    }
    else {
        cout << "pairwise coprime" << endl;
    }
}

Measured memory_bytes: 70348
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int k;
	cin >> k;
	vector<int> s = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
	};
	cout << s[k - 1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int a,b;
    cin >> a >>b;
    if(a<10 && b<10) cout << a*b << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <list>
#include <string>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

struct data_t
{
    int i;
    string s;
    int p;

    // 最後のconstを忘れると"instantiated from here"というエラーが出てコンパイルできないので注意
    bool operator<(const data_t &right) const
    {
        return s != right.s ? s < right.s : p > right.p;
    }
};

int main()
{
    int N;
    cin >> N;
    int W[N];
    int total = 0;
    REP(i, N)
    {
        int w;
        cin >> w;
        W[i] = w;
        total += w;
    }

    int ret = 100 * 100;
    int s1 = 0;
    for (int i = 0; i < N; i++)
    {
        s1 += W[i];
        int s2 = total - s1;
        if (ret > abs(s1 - s2))
        {
            ret = abs(s1 - s2);
        }
    }

    cout << ret << endl;
}

void cheatsheet()
{
    // loop
    // vector<int> vec(10);
    vector<int> vecloop;
    REP(i, 10)
    {
        vecloop.push_back(i);
    }

    // swap
    int a = 1;
    int b = 5;
    swap(a, b); // -> a = 5, b = 1

    // sort
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    sort(arr, arr + 9, greater<int>()); // 9 8 7 6 5 4 3 2 1

    // lower
    vector<int> vec(arr, end(arr));
    sort(vec.begin(), vec.end());
    cout << lower_bound(vec.begin(), vec.end(), 2)[0]; // 2

    // map
    map<Pll, ll> m;
    m[Pll(10, 100)] = 100;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;
typedef long long int ll;
int main(void){
  ll N,K;
  cin >> N >> K;
  vector<ll> A,F;

  for(int i=0;i<N;i++){
    ll tmp;
    cin >> tmp;
    A.push_back(tmp);
  }

  for(int i=0;i<N;i++){
    ll tmp;
    cin >> tmp;
    F.push_back(tmp);
  }
  sort(A.begin(),A.end());
  sort(F.begin(),F.end(),greater<ll>());

  ll max = 0;
  ll sumA = 0;
  for(int i=0;i<A.size();i++){
    ll tmp = A[i]*F[i];
    sumA = sumA + A[i];
    if(max < tmp){
      max = tmp;
    }
  }
  if(sumA <= K){
    cout << 0 << endl;
    return 0;
  }
  //0にできない場合二分探索
  ll l,r;
  l=0;
  r=max;
  while(r-l>1){
    ll c = (r+l)/2;
    // cは達成できるか？
    bool flag = true;
    ll sum = 0;
    for(int i=0;i<A.size();i++){
      ll k = ceil(A[i] - c/(double)F[i]);
      if(k<0)
	k=0;
      sum = sum + k;
      if(sum > K){
        flag = false;
        break;
      }
    }
    //cout << r << " " << l << " " << c << endl;
    if(flag){
      r = c;
    }else{
      l = c;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 4848
import sys


def solv(a, b, n):
    x = list(str(float(a) / float(b) - a / b))[2:]
    x = map(int, x)
    if n <= len(x):
        return sum(x[:n])
    else:
        return sum(x)


for line in sys.stdin:
    a, b, n = tuple(map(int, line.split(' ')))
    print solv(a, b, n)

Measured memory_bytes: 4248
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 1000000001
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}

int bs(vector<int> s,int a,int b,int x);

int main(){
	
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)cout<<c<<endl;
	if(a==c)cout<<b<<endl;
	if(c==b)cout<<a<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n, a[100005];
int main() {
	cin >> n; if (n == 1) { cout << "1" << endl; return 0; }
	for (int i = 0; i < n; i++)cin >> a[i];
	int cnt = 0, J = 0, K = -1;
	for (int i = 0; i <= n; i++) {
		if (i == n) { cnt++; break; }
		if (K == -1 && i != 0) {
			if (J > a[i])K = 1; if (J < a[i]) K = 0;
		}
		else {
			if (K == 0 && a[i - 1] > a[i]) { cnt++; J = a[i]; K = -1; }
			if (K == 1 && a[i - 1] < a[i]) { cnt++; J = a[i]; K = -1; }
		}
		J = a[i];
	}
	cout << cnt << endl;
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

int main() {
	int x;
	cin >> x;
	if (x >= 30) {
		ps(Yes);
	}
	else {
		ps(No)
	}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int MAX = 250005;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
 
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    int H, W, A, B; cin >> H >> W >> A >> B;

    ll ans = 0LL;
    COMinit();

    for(int i=1; B+i<=W; i++){
        ans += (COM(H-A-1+B+i-1, B+i-1) * COM(A-1+W-B-i, W-B-i))%mod;
        ans %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6144
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<int> en;map<int,int> de;
int a[114514];
int main()
{
	int n;lint out=0;
	scanf("%d",&n);
	rep(i,n) scanf("%d",&a[i]);
	//rep(i,n) cout<<a[i]<<endl;
	rep(i,n) en.pb(a[i]);
	sort(All(en));
	rep(i,n) de[en[i]]=i;
	rep(i,n) a[i]=de[a[i]];
	rep(i,n){
		if((i+a[i])%2>0) out++;
	}
	cout<<out/2<<endl;
}


Measured memory_bytes: 5752
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d; 
	
	ll ans = -INF;
	ans = max(ans, a * c);
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);
	if((a <= 0 && b >= 0) || (c <= 0 && d >= 0)) ans = max(ans, 0ll);
	
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

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 ll INF = 1LL << 60;

//---main---------------------------------------------
int main(){
    //main
    string S,T;
    cin >> S >> T;
    int ans = 0;
    rep(i,S.size()) if(S[i]!=T[i]) ans++; 

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3860
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int k;
	cin >> k;
	string n;
	cin >> n;
	int e = 0;
	int w = 0;
	for (int i = 0; i < n.size(); i++) {
		if (n[i] == 'E') {
			e++;
		}
		else {
			w++;
		}
	}
	int le = 0;
	int lw = 0;
	int ans = 100000000000;
	for (int i = 0; i < n.size(); i++) {
		int en = 0;
		int wn = 0;
		if (n[i] == 'E') {
			en++;
		}
		else {
			wn++;
		}
		if (lw + e - en < ans) {
			ans = lw + e - en;
		}
		le = le + en;
		lw = lw + wn;
		e = e - en;
		w = w - wn;
	}
	cout << ans;
}

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

int main() {
    long long x; cin >> x;
    for (long long i = -1000; i <= 1000; i++) {
        for (long long j = -1000; j <= 1000; j++) {
            long long ans = i * i * i * i * i - j * j * j * j * j;
            // cout << ans << endl;
            if (ans == x) {
                cout << i << " " << j << endl;;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3596
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let _n: usize = util::get();
    let p: Vec<usize> = util::gets();

    let eq: Vec<bool> = p.iter()
        .map(|x| x - 1)
        .enumerate()
        .map(|(a, b)| a == b)
        .collect();
    let streaks: Vec<usize> = {
        let mut r = eq.iter().fold(
            (Vec::new(), 0),
            |(mut v, counter), &b| if b {
                (v, counter + 1)
            } else {
                if counter > 0 {
                    v.push(counter)
                }
                (v, 0)
            },
        );
        if r.1 > 0 {
            r.0.push(r.1);
        }
        r.0
    };

    let double = streaks.iter().map(|&x| x / 2).sum::<usize>();
    let ans = eq.into_iter().filter(|&b| b).count() - double;

    println!("{}", ans);
}


Measured memory_bytes: 6396
import sys,os,platform
if __debug__ and platform.platform()=='Darwin-18.7.0-x86_64-i386-64bit' and os.name=='posix':
    sys.stdin = open('INP01.txt', 'r')  

    # Printing the Output to output.txt file 
    sys.stdout = open('out.txt', 'w') 
x=int(input()) 
print(1-x)

Measured memory_bytes: 75392