akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int gcd(int a, int b)
{
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}

	return b;
}

int main()
{
	int N, X;
	cin >> N >> X;
	vector<int> x(N);
	for (int i = 0; i < N; ++i) {
		int tmp;
		cin >> tmp;
		x[i] = abs(tmp-X);
	}
	sort(all(x));

	if (x.size() == 1) {
		cout << x[0] << endl;
		return 0;
	}

	int ret = gcd(x[1], x[0]);
	for (int i = 2; i < N; ++i) {
		ret = gcd(x[i], ret);
	}

	cout << ret << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

double pythagoras( int a, int b )
{
	return 2 * sqrt( (double)( a * b ) );
}

int main()
{
	int length;

	while( cin >> length ){
		string s;
		getline( cin, s );

		vector< int > curcles;
		stringstream ss( s );
		while( !ss.eof() ){
			int r;
			ss >> r;
			curcles.push_back( r );
		}
		sort( curcles.begin(), curcles.end() );

		double width = 0.f;
		int f = 0, b = curcles.size() - 1;
		int minR = 0, maxR = 0;
		int edge1 = curcles[ f++ ], edge2 = edge1;
		for( int i = 0; i < (int)curcles.size() - 1; ++i ){
			minR = curcles[ f ];
			maxR = curcles[ b ];
			if( maxR - edge1 > edge2 - minR ){
				width += pythagoras( edge1, maxR );
				edge1 = maxR;
				--b;
			}else{
				width += pythagoras( edge2, minR );
				edge2 = minR;
				++f;
			}
			if( edge1 > edge2 ){
				swap( edge1, edge2 );
			}
		}
		width += edge1 + edge2;

		cout << ( width <= length ? "OK" : "NA" ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1236
// finish date: 2018/01/20
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000


int main() {
    string N;
    cin >> N;
    if (N[0] == '9' || N[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using xy = pair<double, double>;
constexpr xy PARA = xy(-1010101, -2020202);

struct point {
  double x, y, z;
};

struct line {
  long x, y, z, l;
};

double dist(point a, point b) {
  double ret = 0;
  ret += pow((a.x - b.x), 2);
  ret += pow((a.y - b.y), 2);
  ret += pow((a.z - b.z), 2);
  return sqrt(ret);
}

bool isReachable(point p, const vector<line>& v) {
  for (line l: v) {
    point lp = {double(l.x), double(l.y), double(l.z)};
    if (dist(lp, p) > l.l + 1e-8) {
      // cout << "Unreachable! dist: " << dist(lp, p) << ", l: " << l.l << endl;
      return false;
    }
  }
  return true;
}

double getz(double x, double y, line l) {
  if (pow(l.l, 2) - pow(x - l.x, 2) - pow(y - l.y, 2) < 0) return 0;
  return sqrt(pow(l.l, 2) - pow(x - l.x, 2) - pow(y - l.y, 2));
}


xy getcross(double a1, double a2, double b1, double b2, double c1, double c2) {
  if (abs(a1 * b2 - a2 * b1) < 1e-10) return PARA;

  double x = (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1);
  double y =  -(a2 * c1 - a1 * c2) / (a1 * b2 - a2 * b1);
  return xy(x, y);
}

void solve(long n) {
  vector<line> v;
  long x, y, l;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> l;
    v.push_back({x, y, 0, l});
  }
  double ans = -1e18;

  for (int i = 0; i < n; i++) {
    double z = v[i].l;
    if (isReachable({double(v[i].x), double(v[i].y), double(z)}, v)) {
      ans = max(ans, z);
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (v[i].l + v[j].l < dist({double(v[i].x), double(v[i].y), 0}, {double(v[j].x), double(v[j].y), 0})) {
        continue;
      }
      double z;
      double a = dist({double(v[i].x), double(v[i].y), 0}, {double(v[j].x), double(v[j].y), 0});
      double k = 0.5 * ((pow(v[i].l, 2) - pow(v[j].l, 2)) / pow(a, 2) + 1);
      double xx = v[i].x + k * (v[j].x - v[i].x);
      double yy = v[i].y + k * (v[j].y - v[i].y);
      z = getz(xx, yy, v[i]);
      if (isReachable({xx, yy, z}, v)) {
        ans = max(ans, z);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        double x1 = v[i].x;
        double y1 = v[i].y;
        double x2 = v[j].x;
        double y2 = v[j].y;
        double x3 = v[k].x;
        double y3 = v[k].y;
        xy xxyy = getcross(2 * (x1 - x2), 2 * (x2 - x3), 2 * (y1 - y2), 2 * (y2 - y3),
          pow(x1, 2) - pow(x2, 2) + pow(y1, 2) - pow(y2, 2) - pow(v[i].l, 2) + pow(v[j].l, 2),
          pow(x2, 2) - pow(x3, 2) + pow(y2, 2) - pow(y3, 2) - pow(v[j].l, 2) + pow(v[k].l, 2)
        );
        if (xxyy == PARA) continue;
        double xx = xxyy.first;
        double yy = xxyy.second;
        double z = getz(xx, yy, v[i]);
        // cout << "hoge" << endl;
        // cout << xx << " " << yy << " " << z << endl;
        if (isReachable({xx, yy, z}, v)) {
          ans = max(ans, z);
        }
      }
    }
  }

  printf("%.8f\n", ans);
}

int main() {
  long n;
  while (1) {
    cin >> n;
    if (n == 0) return 0;
    solve(n);
  }
}



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

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (a < b) printf("%d\n", 2 * b - 1);
	else if (a == b) printf("%d\n", 2 * a);
	else printf("%d\n", 2 * a - 1);

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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 MOD = 1e9+7;

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    // k 番目のノードについて遅延評価を行う
    void eval(int k, int l, int r) {

        // 遅延配列が空でない場合、自ノード及び子ノードへの
        // 値の伝播が起こる
        if(lazy[k] != 0) {
            node[k] += lazy[k];

            // 最下段かどうかのチェックをしよう
            // 子ノードは親ノードの 1/2 の範囲であるため、
            // 伝播させるときは半分にする
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }

            // 伝播が終わったので、自ノードの遅延配列を空にする
            lazy[k] = 0;
        }
    }


    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;

        // k 番目のノードに対して遅延評価を行う
        eval(k, l, r);

        // 範囲外なら何もしない
        if(b <= l || r <= a) return;
        
        // 完全に被覆しているならば、遅延配列に値を入れた後に評価
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }

        // そうでないならば、子ノードの値を再帰的に計算して、
        // 計算済みの値をもらってくる
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(b <= l || r <= a) return 0;

        // 関数が呼び出されたら評価！
        eval(k, l, r);
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main(){
    ll N, D, A;
    cin >> N >> D >> A;
    vector<pair<ll, ll> > XH;
    REP(i,N){
        ll x, h;
        cin >> x >> h;
        XH.emplace_back(x, h);
    }

    sort(XH.begin(), XH.end());

    vector<ll> X;
    vector<ll> H;
    for(auto&& p : XH){
        X.push_back(p.first);
        H.push_back(p.second);
    }

    LazySegmentTree tree(H);

    ll ans = 0;
    REP(i,N){
        ll val = tree.getsum(i, i+1);
        if(val <= 0) continue;
        ll bomb = val/A + (val%A != 0);
        ans += bomb;
        ll add = bomb * A;
        int idx = upper_bound(X.begin(), X.end(), X[i]+2*D) - X.begin();
        tree.add(i, idx, -add);
    }

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


Measured memory_bytes: 20204
#include <iostream>
#include <vector>

using namespace std;
int area[100001];
int main() {
    char S[100001];
    cin >> S;
    
    char before = 'R';
    int score = 1;
    int len = 1;
    for (int i=1; S[i] != 0; i++, len++) {
        if (S[i] == 'L') {
            if (before == 'R') {
                area[i-1] += score/2 + (score%2);
                area[i] += score/2;
            }
            score = 0;
        }
        else {
            score++;
        }
        before = S[i];
    }

    score = 1;
    before = 'L';
    for (int i=len-2; i>=0; i--) {
        if (S[i] == 'R') {
            if (before == 'L') {
                area[i+1] += score/2 + (score%2);
                area[i] += score/2;
            }
            score = 0;
        }
        else {
            score++;
        }
        before = S[i];
    }
    for (int i=0; i<len; i++) {
        cout << area[i];
        if (i < len-1) cout << " ";
        else cout << endl;
    }
    return 0;
}



Measured memory_bytes: 896
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.i();
        int K = in.i();
        int[] A = in.ii(N);

        for (int i = K; i < N; i++) {
            out.println(A[i - K] < A[i] ? "Yes" : "No");
        }
        out.flush();
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

using namespace std;

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

  int n;
  long long res = 0;
  cin >> n;
  map<string, long long> count;
  string s;
  while (n--) {
    cin >> s;
    sort(s.begin(), s.end());
    count[s]++;
  }
  for (auto &c : count) {
    if (c.second > 1) 
      res += (c.second * (c.second-1)) / 2;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 11264
/**
 *    author:  FromDihPout
 *    created: 2020-08-15
**/

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


const long long INF = 5e18;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<int> p(n), a(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
  
	long long ans = -INF;
	for (int s = 0; s < n; s++) {
		vector<bool> seen(n);
		vector<long long> score(n+1);
		int curr = s, cycle = 1;
		for (cycle = 1; cycle <= k; cycle++) {
			curr = p[curr];
			if (seen[curr]) break;
			seen[curr] = true;
			score[cycle] = a[curr] + score[cycle-1];
		}
		cycle--;

		for (int i = 1; i <= cycle; i++) {
			ans = max(ans, score[i]);
			ans = max(ans, ((k - i) / cycle) * score[cycle] + score[i]);
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3640
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const alpha = input[0][0];

  return alpha !== alpha.toLowerCase() ? "A" : "a";
};

console.log(main(read()));


Measured memory_bytes: 29676
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = sc.next();
    String[] rank = s.split("");
    int d = 0;
    int e = 0;
    for (int i = 0; i < n; i++){
      if (rank[i].equals("a") && d < a+b){
        System.out.println("Yes");
        d++;
      }else if ((rank[i].equals("b") && d < a+b) && e < b){
        System.out.println("Yes");
        d++;
        e++;
      }else{
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 62044
#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

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

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);
    unsigned ll a;
    string b;
    cin >> a >> b;
    unsigned ll b_ll = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');

    cout << a*b_ll / 100 << endl;
}

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

using namespace std;

int stringToInt(string input) {
    stringstream converter(input);
    int result = 0;
    converter >> result;
    return result;
}

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

    int lowestDiffrence = 1000;
    for (int i = 0; i<input.size()-2; i++) {
        string numberProvider = "   ";
        numberProvider[0] = input[i];
        numberProvider[1] = input[i+1];
        numberProvider[2] = input[i+2];
        int comparable = stringToInt(numberProvider);

        int difference;
        if (753 >= comparable)
            difference = 753-comparable;
        else
            difference = comparable-753;

        if (difference < lowestDiffrence)
            lowestDiffrence = difference;
    }

    cout << lowestDiffrence;
    return 0;
}

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

using namespace std;

int main()
{
   int a,b,p,q,r;
   int temp=0;
   cin >> a>>b;
   
   for(p=0;p<1500;p++){
   	
   	
   	if(floor(p*0.08)==a && floor(p*0.1)==b){
   	    temp = p;
   	    break;
	   }
	   
	 }
	 if(temp==0){
	 	cout << -1;
	 }
	 else{
	 	cout << temp;
	 }
   
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	char b[305][305];
	for (int i = 0; i < 305; i++) {
		for (int j = 0; j < 305; j++) {
			b[i][j] = '.';
		}
	}
	int h, w;
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", b[i]);
	}
	int a[600][600];
	for (int i = 0; i < 600; i++) {
		for (int j = 0; j < 600; j++) {
			a[i][j] = 0;
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (b[i][j] == '#') {
				a[i - j + 300][i + j + 1] = 1;
			}
		}
	}
	int r[600][600];
	for (int i = 0; i < 600; i++) {
		r[i][0] = 0;
		for (int j = 1; j < 600; j++) {
			if (a[i][j])r[i][j] = r[i][j - 1] + 1;
			else r[i][j] = r[i][j - 1];
		}
	}
	int y[600][600];
	for (int i = 0; i < 600; i++) {
		y[i][0] = 0;
		for (int j = 1; j < 600; j++) {
			if (a[j][i])y[i][j] = y[i][j - 1] + 1;
			else y[i][j] = y[i][j - 1];
		}
	}
	int u, v;
	long long ans = 0;
	for (int i = 0; i < 600; i++) {
		for (int j = 0; j < 600; j++) {
			for (int k = j + 1; k < 600; k++) {
				if (a[i][j] && a[i][k]) {
					u = i - (k - j);
					v = i + (k - j);
					if (u >= 0) {
						ans += (r[u][k-1] - r[u][j-1]);
					}
					if (v < 600) {
						ans += (r[v][k] - r[v][j]);
					}
				}
				if (a[j][i] && a[k][i]) {
					u = i - (k - j);
					v = i + (k - j);
					if (u >= 0) {
						ans += (y[u][k] - y[u][j]);
					}
					if (v < 600) {
						ans += (y[v][k - 1] - y[v][j - 1]);
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4480
#include<iostream>
#include<random>
using namespace std;
int D;
int c[26],s[365][26];
int t[365],now;
int anst[365],ans;
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		now+=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)now-=c[j]*(i-lst[j]);
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	mt19937 rng(114514);
	for(int i=0;i<D;i++)
	{
		anst[i]=t[i]=rng()%26;
	}
	calc();
	ans=now;
	for(int tm=0;tm<2000;tm++)
	{
		int d=rng()%D,q=rng()%26;
		now+=change(d,q);
		t[d]=q;
		for(int k=0;k<2000;k++)
		{
			int d1=rng()%(D-1)+1,d2=rng()%d1;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
		if(ans<=now)
		{
			ans=now;
			for(int i=0;i<D;i++)anst[i]=t[i];
		}
		else
		{
			now=ans;
			for(int i=0;i<D;i++)t[i]=anst[i];
		}
	}
	for(int i=0;i<D;i++)cout<<anst[i]+1<<endl;
	cerr<<ans<<endl;
}


Measured memory_bytes: 3672
//Summer Vacation of 2018
//Atcoder-A: Sharing Cookies
//Author: Jimmy2017
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	
	int c=a+b;
	if(!(a%3)||!(b%3)||!((a+b)%3)){
		cout<<"Possible"<<endl;
	}
	else
	cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
#define All(v) (v).begin(),(v).end()
#define Rep(i,n) for(int i = 0; i < (int)n; i++)
#define Reps(i,n) for(int i = 1; i <= (int)n; i++)
#define For(i,m,n) for(int i = m; i < n; i++)
#define Fors(i,m,n) for(int i = m; i <= n; i++)
#define Inf 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

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

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



int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    Rep(i,n){
        cin >> p[i];
    }
    int num = 0;
    int tmp1,tmp2;
    int cnt = 0;
    For(i,1,n){
        if(p[i] < p[i-1] && cnt == 0){
            tmp1 = i-1;
            cnt++;
        }else if(p[i] < p[i-1] && cnt == 1){
            tmp2 = i;
            cnt++;
        }
    }
    if(cnt > 2){
        cout << "NO" << endl;
        return 0;
    }else if(cnt == 2){
        swap(p[tmp1],p[tmp2]);
    }
    bool ans = true;
    For(i,1,n){
        if(p[i] < p[i-1]){
            ans = false;
            break;
        }
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb       push_back
#define conv(a)  bitset<30>(a).to_string() ;
#define mxpq     priority_queue <int>
#define mnpq     priority_queue<int,vector<int>,greater<int>>
#define S(v)     sort(v.begin(),v.end())
#define RS(v)    sort(v.rbegin(),v.rend())
#define print    printf("%.16f\n", ans)
#define inf      LLONG_MAX
#define mini     LLONG_MIN
#define T        int tc;cin>>tc;while(tc--)
#define int      long long 
#define MAXN     10000001
#define M        1000000007
#define fio      cin.sync_with_stdio(false) ; cin.tie(0);cout.tie(0) ;
#define endl     "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;


void Xarr(){
     
        int n,k ; cin>>n>>k ;
        vector<int> dp(n+1) ;
        for(int i=1;i<=n;i++) dp[i]=dp[i-1]+i ;    
        int ans=0;
        for(int i=k;i<=n;i++){
             int p=dp[i-1] ;
             int q=dp[n]-dp[n-i] ;
             ans+=(q-p+1) ;
             ans%=M ; 
        }    
        cout<<++ans<<endl ;
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
int32_t main(){
 
    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    #ifndef ONLINE_JUDGE
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif
    
    cout << setprecision(9) << fixed;
     clock_t z = clock();
     
     Xarr();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
 
     return 0;

}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
using namespace std;
int n, m;
string s;
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> s;
            if (s == "snuke") {
                cout << (char)(j + 'A' - 1) << i << endl;
                return 0;
            }
        }
    }
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define int         long long
    #define pb          push_back
    #define vi          vector<int>
    #define all(a)      (a).begin(),(a).end()
    #define F           first
    #define S           second
    #define INF         1e18
    const int N = 300 + 5, K = 501;

    void solve(){
        int n;
        cin>>n;
        vi v(n);
        for(int i=0; i<n; i++)
            cin>>v[i];
        sort(all(v), greater<int>());
        int ans = v[0], k = 2;
        for(int i=1; i<n; i++){
            if(k<n){
                ans += v[i];
                k++;
            }
            if(k<n){
                ans += v[i];
                k++;
            }
        }
        cout<<ans<<endl;
    }

    int32_t main()
    {
        IOS;
        int TESTS=1;
        // cin>>TESTS;
        while(TESTS--)
        {       
            solve();
        }
        return 0;
    }

Measured memory_bytes: 4780
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
t = [ir() for i in range(n)]
import fractions
ans = 1
for num in t:
    f=fractions.gcd(ans,num)           #最大公約数
    ans=(ans*num//f)                   #最小公倍数
print(ans)

Measured memory_bytes: 73000
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end());
#define REVERSE(v) reverse(v.begin(), v.end());
using namespace std;


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


int main(){
	ll N;
	cin>>N;
	vector<ll> a(3*N);
	ll sum=0;
	REP(i,3*N)	cin>>a[i];
	
	
	SORT(a);
	REVERSE(a)
	REP(i,N) sum+=a[2*i+1];
	
	cout<<sum<<endl;
	return 0;
}

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

int main() {
  int n,m;
  double p;
  cin >> n >> m >> p;
  p/=100;
  int c[1<<n];
  double d[1<<n];
  memset(c,0,sizeof(c));
  for(int i=0; i<m; i++) {
    int x,y;
    cin >> x >> y;
    x--;y--;
    for(int t=1; t<(1<<n); t++) {
      if((t&(1<<x)) && (t&(1<<y))) c[t]++;
    }
  }
  fill(d,d+(1<<n),1);
  for(int t=(1<<(n-1)); t<(1<<n); t++) {
    for(int s=(1<<(n-1)); s<t; s++) {
      bool ck=true;
      int r=0;
      for(int i=0; i<n; i++) {
	if(!(t&(1<<i)) && (s&(1<<i))) ck=false;
	if((t&(1<<i)) && !(s&(1<<i))) r|=(1<<i);
      }
      if(!ck) continue;
      double q=1;
      for(int i=0; i<c[t]-c[s]-c[r]; i++) q*=p;
      d[t]-=d[s]*q;
    }
  }
  printf("%.10f\n",d[(1<<n)-1]);
  return 0;
}


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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

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

    map<int, int> mmap;
    int n; cin >> n;
    for (int i = 0; i < n; i++){
        int t; cin >> t;
        mmap[t]++;
    }
    vector<pii> vec;
    for (auto it : mmap){
        vec.emplace_back(it);
    }
    n = (int)vec.size();
    int res = 0;
    for (int i = 0; i < n; i++){
        int cur = vec[i].Y;
        if (i && vec[i-1].X + 1 == vec[i].X) cur += vec[i-1].Y;
        if (i != n-1 && vec[i+1].X - 1 == vec[i].X) cur += vec[i+1].Y;
        res = max(res, cur);
    }
    cout << res << endl;
}


Measured memory_bytes: 3840
#include <stdio.h>

int main(void)
{
  int num[50], c = 0;
  double h[50], w[50];

  while(scanf("%d,%lf,%lf", &num[c], &w[c], &h[c]) != EOF){
    if((w[c]/(h[c]*h[c])) >= 25){
      printf("%d\n", num[c]);
    }
    c++;
  }

  return 0;
} 

Measured memory_bytes: 628
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
from itertools import permutations as perm


N = int(input())
#H1,M1,H2,M2,K= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())
l=[]
for i in range(N):
    B = int(input())
    l.append(B)
m=max(l)
x=l.copy()
x.remove(m)
n=max(x)
for i in l:
    if i!=m:
        print(m)
    else:
        print(n)


Measured memory_bytes: 14076
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[2][100];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int j = 0; j < 2; ++j)
    {
        for (int i = 0; i < n; ++i)
            cin >> a[j][i];
        if (j == 1)
            for (int i = n - 2; i >= 0; --i)
                a[j][i] += a[j][i + 1];
    }
    int sol = a[0][0], sum = 0;
    for (int i = 0; i < n; ++i)
    {
        sum += a[0][i];
        sol = max(sol, sum + a[1][i]);
    }
    cout << sol;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
	int n;bool flag=false;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		char ch[50];
		scanf("%s",ch);
		if(ch[0]=='Y')flag=true;
	}
	if(flag)puts("Four");else puts("Three");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int k;
    cin >> k;
    cout << (k / 2) * (k - k / 2) << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
	int N, M;
	int[] X, Y;

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		M = sc.nextInt();
		X = new int[M];
		Y = new int[M];
		int[] deg = new int[N];
		for (int i = 0; i < M; ++i) {
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
			--X[i];
			--Y[i];
			++deg[X[i]];
			++deg[Y[i]];
		}
		int[] sz = new int[N];
		Arrays.fill(sz, 1);
		boolean[] del = new boolean[N];
		for (int i = 0; i < M; ++i) {
			if (deg[X[i]] < deg[Y[i]]) {
				del[Y[i]] = true;
			} else if (deg[Y[i]] < deg[X[i]]) {
				del[X[i]] = true;
			} else {
				if (X[i] > Y[i]) {
					del[X[i]] = true;
				} else {
					del[Y[i]] = true;
				}
				++sz[X[i]];
				++sz[Y[i]];
			}
		}
		long ans1 = 0, ans2 = 1;
		for (int i = 0; i < N; ++i) {
			if (!del[i]) {
				++ans1;
				ans2 = (ans2 * sz[i]) % (1_000_000_000 + 9);
			}
		}
		System.out.println(ans1);
		System.out.println(ans2);
	}

}

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

int main(void){
	int n;
	cin >> n;
	map<char, long long> s;
	for(int i = 0; i < n; ++i){
		string tmp;
		cin >> tmp;
		s[tmp[0]]++;
	}
	long long ans = 0;
	string ma = "MARCH";
	for(int i = 0; i < 5; ++i){
		for(int j = i+1; j < 5; ++j){
			for(int k = j+1; k < 5; ++k){
				ans += s[ma[i]]*s[ma[j]]*s[ma[k]];
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1e9+7;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<int> c(n);
    for(auto&i:c) in>>i;
    sort(c.rbegin(),c.rend());
    modint ans{};
    fr(i,n){
        ans+=pwr(2,2*n-2)*(i+2)*c[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#ifndef ___GEOMETRY_LIBRARY
#define ___GEOMETRY_LIBRARY

#include <vector>
#include <algorithm>

template<class type>
class point2d {
public:
	type x, y;
	point2d() : x(type(0)), y(type(0)) {};
	point2d(type x_, type y_) : x(x_), y(y_) {};
	bool operator==(const point2d& p) { return x == p.x && y == p.y; }
	bool operator!=(const point2d& p) { return x != p.x || y != p.y; }
	point2d& operator+=(const point2d& p) { x += p.x; y += p.y; return *this; }
	point2d& operator-=(const point2d& p) { x -= p.x; y -= p.y; return *this; }
	point2d& operator*=(type val) { x *= val; y *= val; return *this; }
	point2d& operator/=(type val) { x /= val; y /= val; return *this; }
	point2d operator+(const point2d& p) const { return point2d(*this) += p; }
	point2d operator-(const point2d& p) const { return point2d(*this) -= p; }
	point2d operator*(type val) const { return point2d(*this) *= val; }
	point2d operator/(type val) const { return point2d(*this) /= val; }
	type norm() const { return x * x + y * y; }
	type abs() const { return type(std::sqrt(x * x + y * y)); }
	long double fabs() const { return std::sqrt((long double)(x * x + y * y)); }
	type dot(const point2d& p) const { return x * p.x + y * p.y; }
	type cross(const point2d& p) const { return x * p.y - y * p.x; }
	int ccw(const point2d& p1, const point2d& p2) const {
		point2d pr1 = p1 - point2d(*this);
		point2d pr2 = p2 - point2d(*this);
		if (pr1.cross(pr2) != 0) return pr1.cross(pr2) > 0 ? 1 : -1;
		if (pr1.dot(pr2) < 0) return 2;
		return pr1.norm() < pr2.norm() ? -2 : 0;
	}
};

template<class type>
class segment2d {
public:
	point2d<type> p1, p2;
	segment2d() : p1(point2d<type>()), p2(point2d<type>()) {};
	segment2d(const point2d<type>& p1_, const point2d<type>& p2_) : p1(p1_), p2(p2_) {};
	type norm() const { return (p1 - p2).norm(); }
	type abs() const { return (p1 - p2).abs(); }
	long double fabs() const { return (p1 - p2).fabs(); }
};

#endif // ___GEOMETRY_LIBRARY

#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	segment2d<double> s;
	cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
	int q;
	cin >> q;
	cout.precision(15);
	for (int i = 0; i < q; ++i) {
		point2d<double> p;
		cin >> p.x >> p.y;
		double r = (p - s.p1).dot(s.p2 - s.p1) / (s.p2 - s.p1).norm();
		point2d<double> ans = s.p1 + (s.p2 - s.p1) * r;
		cout << ans.x << ' ' << ans.y << '\n';
	}
	return 0;
}


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int n, k;
    cin >> n >> k;

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

    cout << 1 + ceil(double(n-k)/(k-1)) << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<stdio.h>
using namespace std;

int main()
{
int a,b;
	char  op;
	
	while(1){
	scanf("%d %c %d",&a,&op,&b); 
		
		if(op=='+'){
		
		cout<<a+b<<endl;}
		if(op=='-'){
			
		cout<<a-b<<endl;}
		if(op=='*'){
		
		cout<<a*b<<endl;}
		
		if(op=='/'){
			
		cout<<a/b<<endl;}
		if(op=='?')
		break;
	}
	
		return 0;
}

Measured memory_bytes: 3116
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

A, B, C = ri_()
K = ri()
cnt = 0
while 1:
    if A >= B:
        B *= 2
        cnt += 1
    elif B >= C:
        C *= 2
        cnt += 1
    else:
        break
print('Yes' if cnt <= K else 'No')

Measured memory_bytes: 9196
object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val eis = Seq.fill(sc.nextInt)(Seq.fill(sc.nextInt)((sc.nextInt - 1, sc.nextInt))).zipWithIndex
	
	println((0 until (1 << eis.length)).filter { c =>
		eis.filter {case (e, i) => (c >> i & 1) == 1} forall {_._1 forall {case (x, y) => (c >> x & 1) == y}}
	}.map{Integer.bitCount(_)}.max)
}

Measured memory_bytes: 38496
N = int(input())
A = list(map(int, input().split()))
i = 0
ans = 0
while i < N-1:
  if A[i] != i+1:
    pass
  else:
    k = A[i+1]-A[i]
    A[i] += k
    A[i+1] += -k
    ans += 1
  i += 1
if A[N-1] == N:
  ans += 1
print(ans)

Measured memory_bytes: 13880
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

const string ans[7]={"null","one pair","two pair","three card","straight","full house","four card"};

int main(void){
		int a[5];
	while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
		int cnt[13]={},ans_num=0,tmp=0;
		for(int i=0;i<5;++i) ++cnt[a[i]-1];
		for(int i=-1,count=0;i<13+1;++i){
			if(cnt[(i+13)%13]>1)break;
			if(cnt[(i+13)%13]==1)++count;
			if(cnt[(i+13)%13]==0)count=0;
			if(count==5) ans_num=4;
		}
		if(!ans_num){
			for(int i=0;i<13;++i){
				if(cnt[i]==4){ans_num=6;break;}
				if(cnt[i]==3)tmp+=3;
				if(cnt[i]==2)tmp+=2;
			}
			if(tmp==5)ans_num=5;
			if(tmp==4)ans_num=2;
			if(tmp==3)ans_num=3;
			if(tmp==2)ans_num=1;
		}
		cout<<ans[ans_num]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
int len;
char str[100];
int main(){
	scanf("%s",str+1);
	len=strlen(str+1);
	if (len%2==1) {puts("No"); return 0;}
	for (register int i=1; i<=len; ++i)
	{
		if (i%2==1 && str[i]!='h') {puts("No"); return 0;}
		if (i%2==0 && str[i]!='i') {puts("No"); return 0;}
	}	
	puts("Yes");
return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
first = []
second = []
for i in range(m):
    a,b = map(int, input().split())
    if a==1:
        first.append(b)
    elif b==n:
        second.append(a)
first_second = set(first)&set(second)
if len(first_second)>0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 21824
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

ll dp[20005];

int main() 
{
    FAST;
    for(ll i=1;i*i<20005;i++)
        for(ll j=1;j*j<20005;j++)
            for(ll k=1;k*k<20005;k++)
                if((i*i)+(j*j)+(k*k)+((i+j+k)*(i+j+k))<20005)
                    dp[(i*i)+(j*j)+(k*k)+((i+j+k)*(i+j+k))]++;
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cout<<dp[2*i]<<'\n';
    subt;
    return 0;
}

Measured memory_bytes: 3940
#include<stdio.h>
#include<math.h>
int main(void)
{
	double a, b, c, d,e,x,y;
	double l;
	scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
	if (a > c)
	{
		e = a;
		a = c;
		c = e;
	}
	if (b > d)
	{
		e = b;
		b = d;
		d = e;
	}
	x = (c - a)*(c - a);
	y = (d - b)*(d - b);
	l = x+y;
	printf("%f", sqrt(l));
	return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int M=2002018,N=2002018;
int n,m,bl[N],col[N],blo;
int ans,sum[N];
struct md{
	int A1,A2;
	int id,l,r;
}q[M];
bool cmp1(const md &a,const md &b){
	return bl[a.l]==bl[b.l]?a.r<b.r:a.l<b.l;
}
bool cmp2(const md &a,const md &b){
	return a.id<b.id;
}
void cg(int x,int add){
	if(add==-1 && sum[col[x]]==1)--ans;
	if(add==1 && sum[col[x]]==0)++ans;
	sum[col[x]]+=add;
}
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main()
{
	n=read();m=read();blo=sqrt(n)+1;
	for(int i=1;i<=n;i++){
		col[i]=read();
		bl[i]=(i-1)/blo+1;
	}
	for(int i=1;i<=m;i++)
		q[i].l=read(),q[i].r=read(),q[i].id=i;
	sort(q+1,q+m+1,cmp1);
	int l(1),r(0);
	for(int i=1;i<=m;i++){
		while(l<q[i].l)cg(l,-1),++l;
		while(l>q[i].l)cg(l-1,1),--l;
		while(r<q[i].r)cg(r+1,1),++r;
		while(r>q[i].r)cg(r,-1),--r;
		q[i].A1=ans;
//		q[i].A2=1LL*(q[i].r-q[i].l)*(q[i].r-q[i].l+1);
//		LL gcd=getgcd(q[i].A1,q[i].A2);q[i].A1/=gcd;q[i].A2/=gcd;
	}
	sort(q+1,q+m+1,cmp2);
	for(int i=1;i<=m;i++)
		printf("%d\n",q[i].A1);
	return 0;
}
/*

*/

Measured memory_bytes: 19356
#include <bits/stdc++.h>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
using namespace std;
const long long MOD = 1e9 + 7;
int N;
int A[3003];
long long dp[3003][3003][2];

int main() {
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }
    for (int i = 1; i <= N; ++i) {
        dp[i][i][0] = dp[i][i][1] = A[i]; //0 MIN 1 MAX
    }
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            int sign = (j) % 2 == 0 ? 1 : -1;
            if (i + j <= N) {
                dp[i][i + j][0] = min(dp[i + 1][i + j][1] + sign * A[i], dp[i][i + j - 1][1] + sign * A[i + j]);
                dp[i][i + j][1] = max(dp[i + 1][i + j][0] + sign * A[i], dp[i][i + j - 1][0] + sign * A[i + j]);
            }
            if (i - j > 0) {
                dp[i - j][i][0] = min(dp[i - j][i - 1][1] + sign * A[i], dp[i - j + 1][i][1] + sign * A[i - j]);
                dp[i - j][i][1] = max(dp[i - j][i - 1][0] + sign * A[i], dp[i - j + 1][i][0] + sign * A[i - j]);
            }
        }
    }
    /*for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j)
            cout << dp[i][j][0] << ' ' << dp[i][j][1] << "         ";
        cout << '\n';
    }*/
    if (N % 2 == 0) cout << -1 * dp[1][N][0];
    else cout << dp[1][N][1];
    return 0;
}


Measured memory_bytes: 139648
#include<iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <stdio.h>
using namespace std;
 
int main(){
    int A, B, C, K;
    cin>> A >>B>> C>> K;
    if(K<=A){
        cout << K<<endl;
    }else{
        if(K<=A+B) cout << A<<endl;
        else cout<<2*A+B-K;
    }

}

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

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int x[100], y[100], a[100];
    rep(i, n) {
        cin >> x[i] >> y[i] >> a[i];
        x[i]--;
        y[i]--;
    }
    int maze[100][100];
    int ans = 0;
    
    rep(i, h) rep(ii, w) maze[i][ii] = 1; 
    
    rep(i, n) {
        int lx, rx, ly, ry;
        
        switch (a[i]) {
            case 1:
                lx = 0; rx = x[i] + 1;
                ly = 0; ry = h;
                break;
            case 2:
                lx = x[i] + 1; rx = w;
                ly = 0; ry = h;
                break;
            case 3:
                lx = 0; rx = w;
                ly = 0; ry = y[i] + 1;
                break;
            case 4:
                lx = 0; rx = w;
                ly = y[i] + 1; ry = h;
                break;
        }
        
        for (int ii = ly; ii < ry; ii++) {
            for (int iii = lx; iii < rx; iii++) {
                maze[ii][iii] = 0;
            }
        }
    }
    
    rep(i, h) {
        rep(ii, w) {
            ans += maze[i][ii];
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    for (int i=0; i<n-1; i++)
        cin >> c[i] >> s[i] >> f[i];
    for (int i=0; i<n; i++) {
        int t = 0;
        for (int j=i; j<n-1; j++) {
            if (t < s[j])
                t = s[j];
            else if ((t-s[j]) % f[j] != 0)
                t += f[j] - (t-s[j]) % f[j];
            t += c[j];
        }
        cout << t << endl;
    }
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int k;

int main()
{
    _FastIO;
    cin >> k;
    int w = 7;
    for(int i = 1; i <= 10000005; i++){
        if(w % k == 0){
            cout << i << endl;
            return 0;
        }
        w *= 10;
        w += 7;
        w %= k;
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 3616
import math
K = int(input())
gcd3 = 0
for a in range(1,K-1):
    for b in range(a+1,K):
        for c in range(b+1,K+1):
            gcd3 += math.gcd(math.gcd(a,b),c)
gcd2 = 0
for a in range(1,K):
    for b in range(a+1,K+1):
        gcd2 += math.gcd(a,b)
ans = gcd3 * 6 + gcd2 * 6 + K*(K+1)//2
print(ans)


Measured memory_bytes: 9192
#include<math.h>
#include<map>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
#include <list>
#include<numeric>
//AtCoderC++.cpp

using namespace std;

int main() {
	string s = "aiueo"; 
	char c; cin >> c;
	for (size_t i = 0; i < 5; i++) {
		if (c == s[i]) {
			cout << "vowel" << endl;
			return 0;
		}
	}
	cout << "consonant" << endl;
}

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

using namespace std;

int main () {
    int n, l;
    cin >> n >> l;

    vector<int> ata(n);
    vector<int> ataab(n);
    for (int i = 0; i < n; i++)
    {
        ata[i] = l + i;
        ataab[i] = abs(ata[i]);
    }

    int min = 200;
    int minID;
    for (int i = 0; i < n; i++)
    {
        if(ataab[i] < min) {
            min = ataab[i];
            minID = i;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if(i != minID) {
            ans += ata[i];
        }

    }

    cout << ans << "\n";
}

Measured memory_bytes: 3640