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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n;
  cin >> n;
  vector<int> v(4,0);
  REP(i,n){
    char c;cin >> c;
    if(c == 'P')v[0]++;
    if(c == 'W')v[1]++;
    if(c == 'G')v[2]++;
    if(c == 'Y')v[3]++;
  }
  int count = 0;
  REP(i,4)if(v[i])count++;
  count == 3 ? cout << "Three" << endl : cout << "Four" << endl;

  





  return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
if abs(x)==abs(y):
  print((x*y<0)+0)
elif x*y==0:
    print(abs(x-y)+(x>0 or y<0)*1)
elif x*y<0:
  print(1+abs(abs(x)-abs(y)))
else:
  if x<y:
    print(abs(x-y))
  else:
    print(2+abs(abs(x)-abs(y)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main() {
    init();
int a,b;
cin>>a>>b;
if(a==1&&b==3||a==3&&b==1){
    cout<<"Yes";
}
else if(a==3&&b==3||b==3&&a==3) {   cout<<"Yes";
}
else if(a==1&&b==1){cout<<"Yes";
}
else
    cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int x[3];
	cin >> x[0];
	for (int i = 1; i < 3; i++)
	{
		cin >> x[i];
		if (x[i - 1] > x[i])
		{
			int copy = x[i];
			x[i] = x[i - 1];
			x[i - 1] = copy;
		}
	}
	if (x[1] < x[0])
	{
		int copy = x[1];
		x[1] = x[0];
		x[0] = copy;
	}
	cout << x[0] << " " << x[1] << " " << x[2] << endl;
	return 0;
}


Measured memory_bytes: 3092
# -*- coding: utf-8 -*-

N = int(input().strip())
AB_list = [list(map(int, input().rstrip().split())) for i in range(N)]

#-----
def gcd(a,b):
    if b == 0: 
        return a
    return gcd(b, a % b)

#-----
fish = {}
cnt_A0_B0 = 0
cnt_A0_Bj = 0
cnt_Ai_B0 = 0
mod = 10**9 + 7


for a,b in AB_list:
    if a == b == 0:
        cnt_A0_B0 += 1
    
    elif (a == 0):
        cnt_A0_Bj += 1
    
    elif (b == 0):
        cnt_Ai_B0 += 1
    
    else:
        g = gcd( abs(a) , abs(b) )
        
        a //= g
        b //= g
        
        if a < 0:
            a *= (-1)
            b *= (-1)
        
        fish.setdefault( (a,b) , 0 )
        fish[ (a,b) ] += 1


ans = 1
used = set()

# multiple the number of pattern, where fish (A != 0) and (B != 0)
for key_a, key_b in fish:
    if (key_a, key_b) not in used:
        
        if key_b >= 0:
            key_reverse = (key_b, -key_a)
        else:
            key_reverse = (-key_b, key_a)
        
        if key_reverse in fish:
            ans *= ( (pow(2, fish[(key_a, key_b)], mod) - 1) + (pow(2, fish[key_reverse], mod) - 1) + 1 ) % mod
            ans %= mod
            
            used.add( key_reverse )
        
        else:
            ans *= ( pow(2, fish[(key_a, key_b)], mod) )
            ans %= mod


# multiple the number of pattern, where fish A=0 or B=0
ans *= ( (2**cnt_A0_Bj - 1) + (2**cnt_Ai_B0 - 1) + 1 ) % mod
ans %= mod

# Add the number of pattern, where fish (A,B)=(0,0)
ans += cnt_A0_B0
ans %= mod

# Minus the number of pattern, where no fish selected
ans -= 1

ans = (ans + mod) % mod
print(ans)


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

using vi = vector<int>;
using vvi = vector<vi>;

void compress(vi const& vec, map<int, int>& zip, vi& unzip){
    unzip = vec;

    sort(begin(unzip), end(unzip));
    unzip.erase(unique(begin(unzip), end(unzip)), unzip.end());

    rep(i, unzip.size()) zip[unzip[i]] = 2 * i + 1;
}

using Rect = tuple<int, int, int, int>;

int w, h;
vvi field;

vi dx = { 1, 0,-1, 0};
vi dy = { 0,-1, 0, 1};

void dfs(int y, int x){
    if(field[y][x] == 0) field[y][x] = 1;
    else return;

    rep(i, 4){
        int ny = y + dy[i], nx = x + dx[i];

        if(ny < 0 or h <= ny or
           nx < 0 or w <= nx) continue;

        dfs(ny, nx);
    }
}

int main(void){
    for(int n; cin >> n, n;){
        vi xs, ys;
        vector<Rect> rects(n);
        rep(i, n){
            int l, a, r, b; cin >> l >> b >> r >> a;
            rects[i] = tie(l, a, r, b);

            xs.push_back(l); xs.push_back(r);
            ys.push_back(a); ys.push_back(b);
        }

        vi unzip_x, unzip_y;
        map<int, int> zip_x, zip_y;

        compress(xs, zip_x, unzip_x);
        compress(ys, zip_y, unzip_y);

        for(auto & e : rects){
            int l, a, r, b;
            tie(l, a, r, b) = e;

            l = zip_x[l], r = zip_x[r];
            a = zip_y[a], b = zip_y[b];

            e = tie(l, a, r, b);
        }

        w = 501, h = 501;
        field = vvi(h, vi(w));
        for(auto & e : rects){
            int l, a, r, b;
            tie(l, a, r, b) = e;

            range(y, a, b + 1){
                field[y][l] = field[y][r] = 1;
            }
            range(x, l, r + 1){
                field[a][x] = field[b][x] = 1;
            }
        }

        int res = 0;
        rep(y, h){
            rep(x, w){
                if(field[y][x] == 0){
                    dfs(y, x);
                    res++;
                }
            }
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 12744
function main(lines) {
    const input = lines.split(' ').map(Number)
    const A = input[0]
    const B = input[1]
    const H = input[2]
    const C = input[3]
    
    const theta = (360) * H/12 + 0.5*C - (360) * C/60
    const output = Math.sqrt( A*A + B*B - 2*A*B*Math.cos(theta * Math.PI/180) )
    console.log(output.toFixed(9))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
  int n,h;
  cin>>n>>h;
  V<int> a(h);
  fo(i,h){
    cin>>a[i];
  }
  int sum=0;
  fo(i,h){
    sum+=a[i];
  }
  if(sum>=n)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}
  


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

using namespace std;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B && A != C){
        cout << "Yes" << endl;
    }
    else if(B == C && A != C){
        cout << "Yes" << endl;
    }
    else if(C == A && B != C){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n;
    cin >> n;
    
    ll ans = 0;
    for(ll i = 1; i <= n; i++) {
        ll a = n/i;
        ans += a*(i + a*i)/2;
        // cout << i << " " << a << " " << a*(i + a*i)/2 << endl;
        
    }

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

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
using pii = pair<int, int>;
int main(){
  int k, t, a;
  std::cin >> k >> t;
  priority_queue<pii> que;    
  // priority_queue<pii, vector<pii>, greater<pii> > que;    
  for (int i = 0; i < t; i++) {
    std::cin >> a;
    que.push(pii(a, i));
  }
  int prev = -1;
  pii memo;
  bool f = false;
  int cut = 0;
  while(que.size() > 1){
    f = false;
    memo = que.top();
    int num = que.top().first;
    int id  = que.top().second;
    que.pop();
    if(id == prev){
      f = true;
      id  = que.top().second;
      num = que.top().first;
      que.pop();
    }
    num--;
    prev = id;
    if(num != 0)que.push(pii(num, id));
    if(f)que.push(memo);
  }
  std::cout << (que.top().first - (que.top().second != prev))<< std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		//Scanner scan = new Scanner(System.in);
		String[] str1 = line.split(",");


			System.out.print(str1[0]);
			System.out.print(" ");
			System.out.print(str1[1]);
			System.out.print(" ");
			System.out.print(str1[2]);

	}
}


Measured memory_bytes: 22864
import itertools

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
m = itertools.permutations(range(1,N+1))

P_id = 0
Q_id = 0

for i,l in enumerate(m):
  if l == tuple(P):
    P_id = i
  if l == tuple(Q):
    Q_id = i

    
print(abs(Q_id - P_id))

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Identically Colored Panels Connection
 */
public class Main {

	enum COLOR {
		NONE, YELLOW, PINK, RED, PURPLE, GREEN, BLUE,
	}

	static int[][] DIR = {
			{1, 0},
			{0, 1},
			{-1, 0},
			{0, -1},
	};

	static COLOR tc;
	static int max = 0;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st;

			st = new StringTokenizer(line);

			int h, w;
			h = parseInt(st.nextToken());
			w = parseInt(st.nextToken());
			tc = COLOR.values()[parseInt(st.nextToken())];
			if ((h | w) == 0) break;

			COLOR[][] pane = new COLOR[h + 2][w + 2];

			for (COLOR[] pp : pane) {
				Arrays.fill(pp, COLOR.NONE);
			}

			for (int i = 0; i < h; i++) {
				st = new StringTokenizer(br.readLine());
				for (int j = 0; j < w; j++) {
					pane[i + 1][j + 1] = COLOR.values()[st.nextToken().charAt(0) - '0'];
				}
			}

			//
			max = 0;

			solve(pane, 5);

			System.out.println(max);
		}
	}

	static void solve(COLOR[][] pane, int r) {

		if (r == 0) {
			if (pane[1][1] == tc) {
				int count = 0;
				Deque<int[]> queue = new ArrayDeque<>();
				queue.offer(new int[]{1, 1});
				while (!queue.isEmpty()) {
					int[] q = queue.poll();
					for (int[] dir : DIR) {
						int ny, nx;
						ny = q[0] + dir[0];
						nx = q[1] + dir[1];
						if (pane[ny][nx] == tc) {
							pane[ny][nx] = COLOR.NONE;
							queue.offer(new int[]{ny, nx});
							count++;
						}
					}
				}
				if (count == 0) count = 1;
				max = Math.max(max, count);
			}
			return;
		}

		COLOR pc = pane[1][1];

		for (COLOR nc : COLOR.values()) {
			if (nc != COLOR.NONE && nc != pc) {
				if (r == 1 && nc != tc) continue;
				COLOR[][] _pane = copy(pane);
				_pane[1][1] = nc;
				//
				Deque<int[]> queue = new ArrayDeque<>();
				queue.offer(new int[]{1, 1});
				while (!queue.isEmpty()) {
					int[] q = queue.poll();
					for (int[] dir : DIR) {
						int ny, nx;
						ny = q[0] + dir[0];
						nx = q[1] + dir[1];
						if (_pane[ny][nx] == pc) {
							_pane[ny][nx] = nc;
							queue.offer(new int[]{ny, nx});
						}
					}
				}
				solve(_pane, r - 1);
			}
		}
	}

	static COLOR[][] copy(COLOR[][] pane) {
		COLOR[][] _pane = new COLOR[pane.length][];
		for (int i = 0; i < pane.length; i++) {
			_pane[i] = pane[i].clone();
		}
		return _pane;
	}
}

Measured memory_bytes: 155576
#include<iostream>

using namespace std;

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

int main(){
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    bool flag = true;
    h[0]--;
    for(int i = 0; i < n - 1; i++){
        if (h[i] < h[i+1]) {
            h[i+1]--;
        }
        if (h[i] > h[i+1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

	
	/* constants */
	#define inf (int)1e+9
	#define VIS 1
	#define UNVIS 0
	#define null NULL
	#define MAX (int)1e+6
	#define MIN -(int)1e+6
	
// ------------------------------------------------------------------------

int n, k;
vector<int> v;
vector<int> memo((int)1e5+5,-1);

int minCost(int pos) {

	if (memo[pos]!=-1)
		return memo[pos];

	if (pos==(n-1))
		return 0;

	if (pos>n)
		return inf;

	int answer=inf;
	for (int i=1; i<=k; i++) {
		answer=min(answer,minCost(pos+i)+abs(v[pos]-v[pos+i]));
	}

	memo[pos]=answer;
	return answer;
}


int main()
{
	
	cin.tie(NULL);
	cout.tie(NULL);

	/*Start*/
	

	scanf("%d%d",&n,&k);
	
	
	v.resize(n);

	for (int i=0; i<n; i++) 
		scanf("%d",&v[i]);


	cout<<minCost(0)<<endl; 
    
    return 0;
}


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

struct Card {char suit, value;};

void bubble(struct Card A[], int N){
    for(int i=0; i<N;i++){
        for(int j=N-1;j>=i;j--){
            if(A[j].value<A[j-1].value){
                Card t=A[j];
                A[j]=A[j-1];
                A[j-1]=t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j].value<A[minj].value) minj=j;
        }
        Card t=A[i];
        A[i]=A[minj];
        A[minj]=t;
    }
}

void print(struct Card A[], int N){
    for(int i=0;i<N;i++){
        if(i>0) cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i=0; i<N; i++){
        if(C1[i].suit!=C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100],C2[100];
    int N;
    char ch;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> C1[i].suit>>C1[i].value;
    }

    for(int i=0; i<N; i++) C2[i]=C1[i];

    bubble(C1,N);
    selection(C2,N);
    print(C1,N);
    cout<<"Stable"<<endl;
    print(C2,N);
    if(isStable(C1,C2,N)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    for(ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d * d) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define endl "\n"
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
ll n,i;
cin>>n;
ld a[n],sum=0;
rep(i,0,n)
cin>>a[i];
sort(a,a+n);
sum=(a[0]+a[1])/2;
rep(i,2,n)
    sum=(sum+a[i])/2;
    cout<<setprecision(10)<<fixed<<sum;
return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{
	int a, b, c, k, e = 0;
	cin >> a >> b >> c >> k;
	while (b <= a)b *= 2, e++;
	while (c <= b)c *= 2, e++;
	puts(e <= k ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3636
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair

vector<ll> uft;

ll search(ll w){
    if(uft[w]==w){return w;}
    ll a=search(uft[w]);
    uft[w]=a;
    return a;
}



int main(){
    ll n;
    cin>>n;
    uft.resize(n);
    for(int i=0;i<n;i++){
        uft[i]=i;
    }
    vector<pll> x,y;
    for(int i=0;i<n;i++){
        ll k,l;
        cin>>k>>l;
        x.push_back({k,i});
        y.push_back({l,i});
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    vector<vector<ll>> road;
    for(int i=1;i<n;i++){
        road.push_back({x[i].F-x[i-1].F,x[i].S,x[i-1].S});
        road.push_back({y[i].F-y[i-1].F,y[i].S,y[i-1].S});
    }
    sort(road.begin(),road.end());
    ll sum=0;
    ll count=1;
    for(int i=0;i<road.size() && count<n;i++){
        if(search(road[i][1])==search(road[i][2])){continue;}
        sum+=road[i][0];
        uft[search(road[i][2])]=search(road[i][1]);
        count++;
    }
    cout<<sum<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 17244
N=int(input())
M=[input().split()[2:]for _ in[0]*N]
q=[0]
d=[0]+[-1]*N
while q:
 u=q.pop(0)
 for v in M[u]:
  v=int(v)-1
  if d[v]<0:d[v]=d[u]+1;q+=[v]
for i in range(N):print(i+1,d[i])


Measured memory_bytes: 5624
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
using namespace std;
using ll= long long;
int main() {
	string S;
	cin >> S;
	int count = 0;
	int k = 0;
	int count0=0;
	int count1=0;


	while (S[k]) {
		count++;
	
		if (S[k] == '0') {

			count0 ++;
		}
		else {
		
			count1++;
		}
		k++;
	}
	ll min;
		min = (count1 <= count0) ? count1 : count0;

	cout << min * 2;


}

Measured memory_bytes: 512
//============================================================================
// Name        : Hello.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {


	int n;
	cin>>n;

	cout<<n/2+n%2<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <bitset>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
const double PI=3.141592653589793238462643383279;
//
int main(){
  int A,B;
  cin>>A>>B;
  int N;
  if(B/100){
    N=A*1000+B;
  }else if(B/10){
    N=A*100+B;
  }else{
    N=A*10+B;
  }
  int i=0;
  while(i*i<N){
    i++;
  }
  if(i*i==N){
    Yes(1);
  }else{
    Yes(0);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

#include <vector>

template <class T = long long int>
class Bit {
    private:
    unsigned len;
    T init;
    std::vector<int> arr;

    public:
    Bit(unsigned length, T initialValue = 0): len(length), init(initialValue), arr(len + 1, init) {}
    void update(unsigned a, T newval) {
        for (unsigned x = a; x <= len; x += x & -x) arr[x] = std::max(arr[x], newval);
    }
    T query(unsigned a) const {
        T ret = init;
        for (unsigned x = a; x > 0; x -= x & -x) ret = std::max(ret, arr[x]);
        return ret;
    }
};

int main() {
    int n;
    std::cin >> n;
    std::vector<int> pts;
    std::vector<std::tuple<int, int, int>> ord;
    for (int i = 0; i < n; i++) {
        int x, l;
        std::cin >> x >> l;
        pts.push_back(x + l);
        pts.push_back(x - l);
        ord.emplace_back(x - l, x + l, i);
    }

    std::sort(ord.begin(), ord.end());
    std::sort(pts.begin(), pts.end());
    pts.erase(std::unique(pts.begin(), pts.end()), pts.end());

    Bit<int> bit(pts.size() + 10);
    for (int i = 0; i < n; i++) {
        int from = std::lower_bound(pts.begin(), pts.end(), std::get<0>(ord[i])) - pts.begin(),
            to = std::lower_bound(pts.begin(), pts.end(), std::get<1>(ord[i])) - pts.begin();
        bit.update(to + 1, bit.query(from + 1) + 1);
    }

    std::cout << bit.query(pts.size() + 10) << std::endl;

    return 0;
}


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

using namespace std;

using i64 = long;

// const i64 MOD = 1e9 + 7;
const i64 MOD = 998244353;
const i64 INF = 1e18 + 7;


auto mpow = [](auto x, i64 y){
    auto z = x;
    decltype(x) val = y & 1 ? x : decltype(x)(1);
    while(z *= z, y >>= 1)
        if(y & 1)
            val *= z;
    return val;
};

template <i64 mod = MOD>
struct ModInt{
    i64 p;

    ModInt() : p(0){}
    ModInt(i64 x){p = x >= 0 ? x % mod : x + (-x + mod - 1) / mod * mod;}

    ModInt& operator+=(const ModInt& y){p = p + *y - ((p + *y) >= mod ? mod : 0); return *this;}
    ModInt& operator-=(const ModInt& y){p = p - *y + (p - *y < 0 ? mod : 0); return *this;}
    ModInt& operator*=(const ModInt& y){p = (p * *y) % mod; return *this;}
    ModInt& operator%=(const ModInt& y){if(y)p %= *y; return *this;}

    ModInt operator+(const ModInt& y) const{ModInt x = *this; return x += y;}
    ModInt operator-(const ModInt& y) const{ModInt x = *this; return x -= y;}
    ModInt operator*(const ModInt& y) const{ModInt x = *this; return x *= y;}
    ModInt operator%(const ModInt& y) const{ModInt x = *this; return x %= y;}

    friend ostream& operator<<(ostream& stream, const ModInt<mod>& x){
        stream << *x;
        return stream;
    }

    friend ostream& operator>>(ostream& stream, const ModInt<mod>& x){
        stream >> *x;
        return stream;
    }

    ModInt& operator++(){p = (p + 1) % mod; return *this;}
    ModInt& operator--(){p = (p - 1 + mod) % mod; return *this;}

    bool operator==(const ModInt& y) const{return p == *y;}
    bool operator!=(const ModInt& y) const{return p != *y;}

    const i64& operator*() const{return p;}
    i64& operator*(){return p;}

};

using mint = ModInt<>;


signed main(){
    i64 m, n, k;
    cin >> m >> n >> k;
    if(m < k || n < k){
        cout << 0 << endl;
        return 0;
    }
    auto calc_fact = [&]{
        constexpr int N = 1e4;
        vector<mint> fact(N + 1, 1);
        vector<mint> inv(N + 1, 1);
        for(int i = 1; i < N; ++i){
            fact[i + 1] = fact[i] * (i + 1);
            inv[i + 1] = mpow(fact[i + 1], MOD - 2);
        }
        return make_pair(fact, inv);
    };
    vector<mint> fact, inv;
    tie(fact, inv) = calc_fact();


    auto ncr = [&fact, &inv](int n, int r){
        if(n < 0 || r < 0 || n < r)
            return mint(0);
        return fact[n] * inv[r] * inv[n - r];
    };



    vector<mint> ncr_table(k, 0);
    vector<mint> fact_table(k, 0);
    ncr_table[1] = mint(m);
    for(int i = 2; i < k; ++i){
        ncr_table[i] = ncr_table[i - 1] * mint(m - i + 1) * mpow(mint(i), MOD - 2);
    }

    vector<mint> dp(k, 0);
    for(int i = 1; i < k; ++i){
        dp[i] = mpow(mint(i), n);
        for(int j = 1; j < i; ++j){
            dp[i] -= dp[j] * ncr(i, j);
        }
    }

    mint ans = mpow(mint(m), n);
    mint ans_minus = 0;
    for(int i = 1; i < k; ++i){
        mint res = dp[i] * ncr_table[i];
        ans_minus += res;
    }
    cout << ans - ans_minus << endl;
}



Measured memory_bytes: 3308
#include <iostream>

using namespace std;

int main()
{
	long long n;
	
	cin >> n;
	
	if(n % 2)
		cout << 0 << '\n';
		
	else
	{
		long long zeros = 0;
		
		while(n >= 5)
		{
			n /= 5;
			zeros += n / 2;	
		}
		
		cout << zeros << '\n';
	}
	
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> a;
  REP(i, n) {
    ll x;
    cin >> x;
    a.push_back(make_pair(x, 1));
  }
  REP(i, m) {
    ll b, c;
    cin >> b >> c;
    a.push_back(make_pair(c, b));
  }
  sort(a.begin(), a.end(), greater<pair<ll, ll>>());

  ll sum = 0;
  ll i = 0, cnt = 0;
  while (cnt < n) {
    ll b = a[i].second, c = a[i].first;
    if (cnt + b <= n) {
      sum += b * c;
      cnt += b;
      i++;
    } else {
      sum += (n - cnt) * c;
      break;
    }
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 6000
import collections
H,W = list(map(int , input().split()))
D = []
for j in range(H):
    x=list(input())
    D.extend(x)
s = len(list((set(D))))
c = collections.Counter(D)
Q = []

for i in range(s):
    Q.append(c.most_common()[i][1])
if s == 1:
    print("Yes")
else:
    if ((H*W)%2 == 1):
        seigen = (H//2+1)*(W//2 +1)
        q = 0
        m = 0
        mm = (H*W-(H//2)*(W//2)*4)//2+1
        for k in range(s):
            q += (Q[k] % 2)
            if (Q[k] % 4)!= 0:
                m += 1
        if (q == 1)and(s<=seigen)and (m <= mm):
            print("Yes")
        else:
            print("No")
    elif ((H%2) == 0)and((W %2) ==0):
        seigen = (H*W)//4
        q = 0
        for k in range(s):
            q += (Q[k] % 4)
        if ((s <= seigen)and(q == 0)):
            print("Yes")
        else:
            print("No")

    else:
        q = 0
        e = 0
        if ((H%2) == 1):
            seigen = (H//2+1)*W
            seigen2 = W//2
        elif ((W%2) == 1):
            seigen = (W//2+1)*H
            seigen2 = H//2
        for k in range(s):
            q += (Q[k] % 2)
            if (Q[k] % 4)!= 0:
                e += 1
        if (q == 0)and(s<=seigen)and(e<=seigen2):
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 3444
input_str = int(input())
result = 0
# 関数を使う
## result = sum([i for i in range(1, input_str+1)])
# 等差数列の和の公式
## result = (input_str * (input_str+1))//2
for i in range(1, input_str+1):
    result += i
print(result)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    if(N % 10 == 7) {
        cout << "Yes" << endl;
    }
    else {
        N /= 10;
        if(N % 10 == 7) {
            cout << "Yes" << endl;
        }
        else if(N / 10 == 7) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3620
N,M=map(int,input().split())
if N>1 and M>1:
  print(int((N*(N-1)/2)+(M*(M-1)/2)))
elif N<=1:
    if M<=1:
      print(0)
    else:
        print(int(M*(M-1)/2))
else:
  print(int(N*(N-1)/2))

Measured memory_bytes: 3060
#include <string.h>
 
#define M 1046527
#define L 14
 
char H[M][L];
 
int char2int(char c) {
  switch (c) {
    case 'A': return 1;
    case 'C': return 2;
    case 'G': return 3;
    case 'T': return 4;
    default: return 0;
  }
}
 
long long getKey(char str[]) {
  long long ret = 0, p = 1;
  int i;
  for(i = 0; str[i] != '\0'; i++) {
    ret += p * char2int(str[i]);
    p *= 5;
  }
  return ret;
}
 
int h1(int key) {
  return key % M;
}
 
int h2(int key) {
  return 1 + (key % (M - 1));
}
 
int find(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}
 
int insert(char str[]) {
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
 
int main(void) {
  int i, n;
  char str[L], cmd[9];
  for(i = 0; i < M; i++) {
    /* initialize hash */
    H[i][0] = '\0';
  }
 
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%s %s", cmd, str);
 
    if(cmd[0] == 'i') {
      insert(str);
    } else {
      if(find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 16020
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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;
 
//conversion
//------------------------------------------
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();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


unsigned gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

LL lcm(LL a, LL b) {
	int g;
	g = gcd(a, b);
    // cout<<g<<endl;
	return a*b/g;
}
LL lcm_n(vector<LL> &numbers) {
	LL l;
	l = numbers[0];
	for (LL i = 1; i < numbers.size(); i++) {
		l = lcm(l, numbers[i]);
	}
	return l;
}
LL gcd_n(vector<LL> numbers){
    LL l;
	l = numbers[0];
	for (LL i = 1; i < numbers.size(); i++) {
		l = gcd(l, numbers[i]);
	}
	return l;
}

void solve(long long N, long long X, std::vector<long long> x){ 
    LL min_diff = 100000000;
    x.PB(X);
    SORT(x);
    vector<LL>diffs;
    REP(i, N){
        LL diff = abs(x[i]-x[i+1]);
        diffs.PB(diff);
    }
    // REP(i, N){
    //     cout<<diffs[i]<<",";
    // }cout<<endl;
    LL val = gcd_n(diffs);
    cout<<val<<endl;
    // int dist = min(X-x[0], x[N-1]-X);
    // int dist2 = max(X-x[0], x[N-1]-X);
    // int ans = 2 * dist/val + dist2/val;
    // cout<<ans<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    solve(N, X, std::move(x));
    return 0;
}


Measured memory_bytes: 2800
n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
count = 0
for k in range(n-2):
    if x[k] == y[k] and x[k+1] == y[k+1] and x[k+2] == y[k+2]:
        count += 1
if count >= 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9192
i = list(map(int,input().split()))
house = list(map(int,input().split()))

ans = []
for h in range(len(house)-1):
  num = house[h+1]-house[h]
  ans.append(num)
l = i[0] - house[-1] + house[0]
ans.append(l)

ans.remove(max(ans))

print(sum(ans))

Measured memory_bytes: 25452
#include<bits/stdc++.h>
using namespace std;
double a[55];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
    	cin>>a[i];
	for(int i=1;i<=n;++i){
		sort(a+i,a+n+1);
		a[i+1]=(a[i+1]+a[i])/2;
	}
	cout<<a[n]<<endl;
}

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

int main() {

    string s;

    cin >> s;

    int ans = s.size()/2; //半分は絶対にできる。

    int left,right;

    char center;

    if(s.size()%2 == 0){
        left = s.size()/2 - 1;
        right = left+1;
        center = s[left];
    }
    else{
        left = s.size()/2 - 1;
        right = left + 2;
        center = s[s.size()/2];
        ans++;
    }



    while(left>=0){
        if(s[left] != center || center != s[right]){
            break;
        }
        ans++;
        left--;
        right++;
    }

    cout << ans << endl;

    return 0;
}

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

typedef pair< pair<int,int> , pair<int,int> > ppp;

int dp[siz][siz];
string s1,s2;

string solve(int siz1,int siz2){
    if(siz1==0||siz2==0){
        return "";
    }
    if(s1[siz1-1]==s2[siz2-1])
        return solve(siz1-1,siz2-1)+s1[siz1-1];
    else if(dp[siz1-1][siz2]>dp[siz1][siz2-1])
        return solve(siz1-1,siz2);
    else
        return solve(siz1,siz2-1);
}

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

  // freopen("street.in","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>s1>>s2;

    for(int i=1;i<=s1.size();i++){
        for(int j=1;j<=s2.size();j++){
            if(s1[i-1]!=s2[j-1])
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            else{
                dp[i][j]=dp[i-1][j-1]+1;
            }
        }
    }

    int siz1=s1.size();
    int siz2=s2.size();
    cout<<solve(siz1,siz2);
return 0;

}

Measured memory_bytes: 35968
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
line = lines.shift().split(' ')
sum = 0
for (i=0;i<N;i++) {
    sum += line[i] * 1
}
bool = true
for (i=0;i<N;i++) {
    if (sum-line[i] * 1 <= line[i] * 1) {
        bool = false
        break;
    }
}
console.log(bool?'Yes':'No')

Measured memory_bytes: 26180
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(0, min(B, D) - max(A, C)) << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
s = list(input())

if s[k-1]=="A":
    s[k-1]=s[k-1].lower()
elif s[k-1]=="B":
    s[k-1]=s[k-1].lower()
elif s[k-1]=="C":
    s[k-1]=s[k-1].lower()

for i in range(n):
    print(s[i],end="")

Measured memory_bytes: 9100
import itertools
N = int(input())
L = list(map(int, input().split()))

count = 0
for i in itertools.combinations(L, 3):
    if i[0] == i[1] or i[1] == i[2] or i[0] == i[2]:
        continue
    if (i[0] < (i[1] + i[2])) and\
    (i[1] < (i[0] + i[2])) and\
    (i[2] < (i[0] + i[1])):
        count += 1
        continue
print(count)


Measured memory_bytes: 9208
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {
    public static Long gcd(Long a, Long b) {
        if (a < b) return gcd(b, a);
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static Long lcm(Long a, Long b) {
        if (a < b) return lcm(b, a);
        return a * b / gcd(a, b);
    }

    public static Long cal(Long a, Long b) {
        Long min_f;
        if(a%b == 0) {
            min_f = a / b;
        } else {
            min_f= (a / b) + 1;
        }
        return min_f;

    }
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Long a = scanner.nextLong();
        Long b = scanner.nextLong();
        Long c = scanner.nextLong();
        Long d = scanner.nextLong();

        Long a_b_min = cal(a,c);
        Long a_b_max = b / c;
        Long total1 = (a_b_max - a_b_min) + 1;

        Long a_d_min = cal(a,d);
        Long b_d_max = b / d;
        Long total2 = (b_d_max - a_d_min) + 1;

        Long lcm = lcm(c,d);
        Long lcm_min = cal(a,lcm);
        Long lcm_max = b / lcm;
        Long total3 = (lcm_max - lcm_min) + 1;

        System.out.println((b-a+1) - (total1+total2-total3));


    }
}


Measured memory_bytes: 23124
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long x=sc.nextLong();
		long tmp=100;
		int count=0;
		while(x>tmp){
			tmp=tmp+(long)(double)tmp/100;
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35872
#include<stdio.h>
long Max(int x);
int main()
{
	int x,n;
	scanf("%d",&x);
	printf("%ld",Max(x));
	return 0;
}
long Max(int x)
{
	if(x==1)
		return 6;
	return (Max(x-1)+1)*2;
}

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

int main()
{
    ll K, X;
    cin >> K >> X;
    cout << X - K + 1;
    for (int i = X - K + 1; i < X + K - 1; i++)
        cout << " " << i + 1;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>

#define MOD 1000000007

using namespace std;

int main()
{
	int n, m, x;
	int tot[13] = { 0, };
	int arr[13][13];
	int cost[13];
	int lmin = 0;

	scanf("%d %d %d", &n, &m, &x);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &cost[i]);

		for (int j = 0; j < m; j++)
		{
			scanf("%d", &arr[i][j]);

			tot[j] += arr[i][j];
		}

		lmin += cost[i];
	}

	for (int i = 0; i < m; i++)
	{
		if (tot[i] < x)
		{
			printf("-1\n");

			return 0;
		}
	}

	const int ub = (int)pow(2.0, n);

	for (int mask = 1; mask < ub; mask++)
	{
		vector<int> bits;

		int temp = mask;

		int cnt = 0;

		int price = 0;

		while(temp)
		{
			if (temp % 2)
			{
				bits.push_back(cnt);

				price += cost[cnt];
			}

			temp /= 2;
			cnt++;
		}

		int sum[13] = { 0, };

		for (int i = 0; i < bits.size(); i++)
		{
			for (int j = 0; j < m; j++)
			{
				sum[j] += arr[bits[i]][j];
			}
		}

		bool valid = true;

		for (int i = 0; i < m; i++)
		{
			if (sum[i] < x)
			{
				valid = false;
				
				break;
			}
		}

		if (valid&&price < lmin)
		{
			lmin = price;
		}
	}

	printf("%d\n", lmin);

	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

void swap ( int *x, int *y ) {
  int temp = *y;
  *y = *x;
  *x = temp;
}

void trace ( int A[], int N ) {
  for ( int i = 0; i < N ; i++ ) {
    printf ( "%d", A[i] );
    if ( i == N - 1 )
      break;
    printf( " " );
  }
  putchar ( '\n' );
}

void selection ( int A[], int N, int cnt) {
  for ( int i = 0; i < N - 1; i++ ) {
    int minj = i;
    for ( int j = i; j < N; j++ ) {
      if ( A[j] < A[minj] ) {
        minj = j;
      }
    }
    if ( i != minj )
      cnt++;
    swap ( &A[minj], &A[i] );
  }
  trace ( A, N );
  printf ( "%d\n", cnt );
}


int main ( void ) {
  int N; int cnt = 0;
  int A[100];
  scanf ( "%d", &N);
  for ( int i = 0; i < N; i++ ) {
    scanf ( "%d", &A[i] );
  }
  selection ( A, N, cnt );
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int n,m,q;
int A[10];
int a[50], b[50], c[50], d[50];
int ans=0;

void dfs(int cur, int size, int range_start, int range_end){
  if(cur==size){
		int tmp=0;
		rep(i,q){
			if(A[b[i]]-A[a[i]]==c[i]) tmp+=d[i];
		}
  	chmax(ans,tmp);
		return;
  }
  for(int next=range_start; next<=range_end; next++){
    A[cur]=next;
    dfs(cur+1,size,next,range_end);
  }
}

signed main(){
	cin>>n>>m>>q;
	rep(i,q){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		a[i]--; b[i]--;
	}
	dfs(0,n,1,m);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3584
#二次元累積和
#https://tqk.hatenablog.jp/entry/ABC106-2
N, M, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
pq = [list(map(int, input().split())) for _ in range(Q)]
train = [[0] * (N + 1) for _ in range(N + 1)]
for L,R in LR:
    train[L][R] += 1
for l in range(1,N+1):
    for r in range(1,N+1):
        train[l][r] += (train[l-1][r] + train[l][r-1] - train[l-1][r-1])
for p, q in pq:
    print(train[q][q]-train[q][p-1]-train[p-1][q]+train[p-1][p-1])

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

template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
const int N=2e5+5;
char s[N];
int nex[N][26],dp[N];

void write(int i)
{
	if(!i)return ;
	int j=0;
	while(dp[nex[i][j]]!=dp[i]-1)++j;
	putchar('a'+j);
	write(nex[i][j]);
}

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	dp[0]=-1;
	for(int i=n;i;--i)
	{
		for(int j=0;j<26;++j)nex[i][j]=nex[i+1][j];
		nex[i][s[i]-'a']=i+1;
		int mn=dp[nex[i][0]];
		for(int j=1;j<26;++j)chmin(mn,dp[nex[i][j]]);
		dp[i]=mn+1;
	}
	write(1);
}

Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define YN(x) cout << ((x) ? "YES" : "NO")
#define Yn(x) cout << ((x) ? "Yes" : "No")
#define yn(x) cout << ((x) ? "yes" : "no")
main(){
    INCANT;
    int a, b, c;
    cin >> a >> b >> c;
    Yn((a - c) * (b - c) < 0);
}

Measured memory_bytes: 256