akhauriyash/Code-Regression huggingface dataset:
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
#include <pthread.h>
#include <omp.h>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

unordered_map<int, int> factor(int n){
  int cnt = 0;
  unordered_map<int, int> m;
  int nn = n;
  while (!(nn & 1))
    cnt++, nn /= 2;
  if(cnt)
    m[2] = cnt;
  for (int i = 3; i <= sqrt(n); i++){
    cnt = 0;
    while(nn % i == 0)
      nn /= i, cnt++;
    if (cnt)
      m[i] = cnt;
  }
  if (nn > 2)
    m[nn] = 1;
  
  return m;
}



Vi g[200100];
bool visited[200100];

int dfs(int v, int par = -1){
  visited[v] = true;
  int cnt = 1;
  for (auto item: g[v])
    if (item != par and not visited[item])
      cnt += dfs(item, v);
  return cnt;
}


bool red[200100];

signed main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  int n;
  cin >> n;
  Vi v1, v2;
  for (int i = 1; i <= sqrt(n); i++)
    if (n % i == 0)
      if (i == n / i)
	v1.pb(i);
      else
	v1.pb(i), v2.pb(n / i);

  for (int i = v2.size() - 1; i >= 0; i--)
    v1.pb(v2[i]);
  
  for (int i = 0; i < v1.size(); i++){
    int diff = v1[i];
    int l = - diff / 2;
    int r = 200;
    int pre_r, pre_l;
    
    while (r > l){
      pre_r = r, pre_l = l;
      int mid = (l + r) / 2;
      int mid_value = pow(mid + diff, 5) - pow(mid, 5);
      if (mid_value < n)
	l = mid;
      else
	r = mid;
      if (r == pre_r and l == pre_l)
	break;
    }
    if (pow(l + diff, 5) - pow(l, 5) == n){
      cout << l + diff << " " << l << endl;
      break;
    }
    if (pow(r + diff, 5) - pow(r, 5) == n){
      cout << r + diff << " " << r << endl;
      break;
    }
  }

}


Measured memory_bytes: 8792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var ab = Input.ar;
        WriteLine(2 * Max(ab[1], ab[0]) - ToInt32(ab[0] != ab[1]));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
#define for0(a, c) for (int(a) = 0; (a) < (c); (a)++)
#define forA(a, b, c) for (int(a) = (b); (a) <= (c); (a)++)
#define forD(a, b, c) for (int(a) = (b); (a) >= (c); (a)--)
#define deb(x) cout<< #x << "=" << x <<endl
#define all(a) a.begin(),a.end()
#define re(x) cin>>x
#define readarr(a,n) for0(i,n) cin>>a[i]
#define mod 1000000007
#define INF 1000000000000000003
#define ff first
#define ss second
#define pb push_back 
#define pob pop_back
#define mp make_pair
#define endl "\n"

typedef long long int            ll;
typedef vector<int>              vi;
typedef pair<int, int>           pi;
typedef unordered_map<int, int>  mii;
typedef unordered_map<char, int> mci;
typedef unordered_set<int>       usi;

int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}

void solve(){
	double n,m;
	re(n),re(m);
	vi arr(n);
	readarr(arr,n);
	sort(all(arr),greater<int>());
	int mm=0;
	int sum=0;
	for0(i,n)
	sum+=arr[i];
	double com = 1/(4*m);
	com = com * sum;
	for0(i,n)
	if(arr[i] >= com)
		mm++;
	if(mm>=m)
		cout<<"Yes";
	else
		cout<<"No";
}

int main(){

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1; 
    // cin>>t;
    while(t--){
      solve();
    }
    return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  ll n,k;
  cin>>n>>k;
  ll a=n%k;
  ll b=abs(k-a);

  cout<<min(a,b);

  return 0;
}


Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    X = il()
    S = sorted(X)
    l = S[N // 2 - 1]
    r = S[N // 2]
    for x in X:
        if x <= l:
            print(r)
        else:
            print(l)


if __name__ == '__main__':
    main()


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}
#define x first
#define y second
int main(){
  int h,w,d; cin >> h >> w >> d;
  int a[300][300];
  map<int,P<int,int>> mp;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      cin >> a[i][j];
      mp[a[i][j]] = {i,j};
    }
  }

  map<P<int,int>,int> dist;
  {
    for(int i = 1; i <= d; ++i){
      int l = i,r = h*w;
      int mem = 0;
      while(l <= r){
	dist[{i,l+d}] = abs(mp[l].x-mp[l+d].x)+abs(mp[l].y-mp[l+d].y) + mem;
	mem = dist[{i,l+d}];
	l+=d;
      }
    }
  }  
  
  int q; cin >> q;
  for(int i = 0; i < q; ++i){
    int l,r; cin >> l >> r;
    int s = l % d; if(s == 0) s = d;
    cout << dist[{s,r}] - dist[{s,l}] << endl;
  }
}


Measured memory_bytes: 24432
<?php
while(1){
  list($n,$x)=explode(' ',trim(fgets(STDIN)));

  if(!$n&&!$x) break;

  $ok=0;
  $ni=$n-2;
  $nj=$n-1;
  for($i=1;$i<=$ni;$i++){
    for($j=$i+1;$j<=$nj;$j++){
      for($k=$j+1;$k<=$n;$k++){
        if(($i+$j+$k)==$x) ++$ok;
      }
    }
  }

  echo $ok,PHP_EOL;
}

Measured memory_bytes: 15244
from collections import*
class UnionFind():
  def __init__(self, n=10**6):
    self.n=n
    self.root=[-1]*(n+1)
    self.rnk=[0]*(n+1)
  def find(self, x):
    if(self.root[x]<0):
      return x
    else:
      self.root[x]=self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x=self.find(x)
    y=self.find(y)
    if(x==y):return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x]+=self.root[y]
      self.root[y]=x
    else:
      self.root[y]+=self.root[x]
      self.root[x]=y
      if(self.rnk[x]==self.rnk[y]):
        self.rnk[y]+=1
  def same(self, x, y):
    return self.find(x)==self.find(y)
  def count(self, x):
    return -self.root[self.find(x)]
n,m=map(int,input().split())
uf=UnionFind(n)
for _ in range(m):
  a,b=map(int,input().split())
  uf.unite(a,b)
a=list(Counter([uf.find(i) for i in range(1,n+1)]).values())
print(max(a))

Measured memory_bytes: 117640
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int n,m;
string t="snuke",s;

int main(){
	cin>>n>>m;
	fore(i,0,n)fore(j,0,m){
		cin>>s;
		if(s==t){printf("%c%d\n",j+'A',i+1);}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <climits>
#include <iomanip>
#include <queue>

using namespace std;

const int N = 2e6 + 9;
const int INF = 2e9 + 2;
const int mod = 1e9 + 7;
const int K = 25;
const int P = 51;
const long long LONG_INF = LONG_MAX;
const int SZ = (1 << 18) - 1;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define mkp make_pair
#define all(s) s.begin(), s.end()

#define ll long long

#define int ll

vector <int> g[N];

int l[N], d[N];

queue <int> q;

int mx = 0;

bool dfs(int v, int pr, int x) {
	l[v] = x;
	x = (x == 1 ? 2 : 1);
	for (auto to : g[v]) {
		if (to == pr)
			continue;
		if (!l[to] and (dfs(to, v, x)))
			return true;
		else if (l[to] and l[v] == l[to])
			return true;
	}
	return false;
}

void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= n; ++ j) {
			char x;
			cin >> x;
			if (x == '1')
				g[i].eb(j);
		}
	}
	if (dfs(1, -1, 1)) {
		cout << -1;
		return;
	}
	for (int i = 1; i <= n; ++ i) {
		q.push(i);
		fill(d + 1, d + 1 + n, INF);
		d[i] = 0;
		while(!q.empty()) {
			int v = q.front();
			q.pop();
			for (auto to : g[v]) {
				if (d[to] > d[v] + 1) {
					d[to] = d[v] + 1;
					mx = max(mx, d[to]);
					q.push(to);
				}
			}
		}
	}
	cout << 1 + mx << '\n';
}


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


Measured memory_bytes: 50176
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N=5005;

int n,m;

int mul[N];
int dp[N];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n/2;i++)
		mul[i+1]=i;
	for(int i=1;i<=(n-1)/2;i++)
		mul[n-i+1]=i+1;
	
	dp[0]=1;
	for(int i=2;i<=n;i++)
		for(int j=mul[i];j<n;j++)
			dp[j]=(dp[j]+dp[j-mul[i]])%m;
	
	int ans=0;
	for(int i=0;i<n;i++)
		ans=(ans+1LL*dp[i]*(n-i))%m;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int N, M; cin >> N >> M;
    vector<int> vl(M+1, 0), vr(M+1, 0);
    for (int i = 1; i <= M; i++) {
        int l, r; cin >> l >> r;
        vl[i] = l; vr[i] = r;
    }

    int left, right; left = vl[1]; right = vr[1];

    for (int i = 1; i <= M; ++i) {
        if (left < vl[i]) left = vl[i];
        if (right > vr[i]) right = vr[i];
        if (right < left) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << right - left + 1 << endl;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long k=sc.nextLong();
    int[] a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt()-1;
    }
    int ans=0;
    while(k>0){
      if((k&1)==1){
        ans=a[ans];
      }
      int[] aa=new int[n];
      for(int i=0;i<n;i++){
        aa[i]=a[a[i]];
      }
      a=aa;
      k=k>>1;
    }
    System.out.println(ans+1);
  }
}

Measured memory_bytes: 60860
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

vector <int> res;

int main(){
    int n;
    cin>>n;
    getchar();
    string St;
    cin>>St;
    for (int i = 0; i < St.length(); i++){
        printf("%c",'A'+(St[i]-'A'+n)%26);
    }

}


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

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

  while (1) {
    string s;
    cin >> s;
    int m;
    cin >> m;
    if (s == "-") {
      break;
    }
    for (int i = 0; i < m; i++) {
      int h;
      cin >> h;
      s += s.substr(0, h);
      s.erase(0, h);
    }
    cout << s << '\n';
  }

}


Measured memory_bytes: 3200
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void) {
    int a,b;
    cin>>a>>b;

    if(a<=b){
        cout<<a<<endl;
    }
    else{
        cout<<a-1<<endl;
    }


}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
const int M = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1000 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    string s, t;
    cin >> s >> t;
    int S = s.size();
    int T = t.size();
    map<char, int> ma_s, ma_t;
    rep(i, S) {
        ma_s[s[i]]++;
    }
    rep(i, T) {
        ma_t[t[i]]++;
    }

    map<int, int> numOfS, numOfT;
    rep(i, 26) {
        char c = 'a' + i;
        numOfS[ma_s[c]]++;
    }
    rep(i, 26) {
        char c = 'a' + i;
        numOfT[ma_t[c]]++;
    }

    if (numOfS == numOfT)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 776
#!/usr/bin/ruby
def x(s)s.size>1&&s[0..0]=='X'end
while(l=gets)
l=~/([0-9X]+)\+([0-9X]+)=([0-9X]+)/
a=$1+'+'+$2+'=='+$3
puts 'NA' if ((x($1)||x($2)||x($3))?1:0).step(9).none?{|i|if eval(a.gsub('X',i.to_s)) then p i;true end}end

Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int check( string S )
{
    //A
    if( S[ 0 ] == '>' && S[ 1 ] == '\'' && S[ S.size() - 1 ] == '~' && S.size() >= 6 )
    {
        S = S.substr( 2, S.size() - 3 );
        if( S.find_first_not_of( "#=", 0 ) != string::npos ) return 0;
        string tmpB = S.substr( 0, S.find('#') );
        string tmpA = S.substr( S.find( '#' ) + 1, S.size() - 1 );
        return tmpB.size() == tmpA.size() ? 1 : 0;
    }
    //B
    if( S[ 0 ] == '>' && S[ 1 ] == '^' && S[ S.size() - 1 ] == '~' && S[ S.size() - 2 ] == '~' && S.size() >= 6 )
    {
        S = S.substr( 2, S.size() - 4 );
        if( S.find_first_not_of( "Q=", 0 ) != string::npos ) return 0;
        if( S.size() % 2 != 0 ) return 0;
        for( int i = 0; i < S.size(); i += 2 )
        {
            if( S[ i ] != 'Q' && S[ i + 1 ] != '=' ) return 0;
        }
        return 2;
    }
    return 0;
}
int main()
{
    int N;
    cin >> N;
    
    vector<string> res{ "NA", "A", "B" };
    string S;
    while( cin >> S )
    {
        cout << res[ check( S ) ] << endl;
    }
    return 0;
}

Measured memory_bytes: 3128
import java.util.*;


public class Main{
	public static void main( String args[] ) {

		int N;
		String A,B,C;
		int counter;
		
		Scanner scan = new Scanner( System.in );
		N = scan.nextInt();
		A = scan.next();
		B = scan.next();
		C = scan.next();
		
		
		counter = 0;
		
		for( int i = 0; i < A.length(); i ++ ) {
			if( A.charAt(i) != B.charAt(i) && A.charAt(i) != C.charAt(i)) {
				if( B.charAt(i) != C.charAt(i))
					counter += 2;
				else {
					counter++;
				}
			}
			else if(A.charAt(i) != B.charAt(i) || A.charAt(i) != C.charAt(i) ) {
				counter++;
			}
			
			//System.out.println( i +":" + counter);
		}
		
				
		System.out.println( counter  );
		
		scan.close();
		
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <stdio.h>
# define M_PI  3.14159265358979323846
using namespace std;

typedef long long ll;
const int N = 1e3 + 9, M = 9e2 + 9, OO = 0x3f3f3f3f;
const double EPS = 0.00000000001;

int n;
char s[200];

bool check(){
	for(int i = 0 ; i < n/2 ; ++i) if(s[i] != s[i+(n/2)]) return 0;
	return 1;
}

int main(){
	//freopen ("i.in","r",stdin);
	//freopen ("no.out","w",stdout);

	scanf("%d", &n);
	scanf(" %s", s);

	if(n%2 != 0) puts("No");
	else (check() ? puts("Yes") : puts("No"));



	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = set()
d = dict()
for i in a:
	if i not in s:
		d[i] = 1
		s.add(i)
	else:
		d[i] += 1
l = list(d.values())
l.sort(reverse=True)
cnt = l.count(1)
if cnt == len(l):
	print(len(l))
else:
	diff = len(l) - cnt
	su = 0
	for i in l:
		if i!=1:
			su += (i-1)
		else:
			break
	if su%2==0:
		print(len(l))
	else:
		print(len(l)-1)

Measured memory_bytes: 20444
n, t = map(int, input().split())
T = list(map(int, input().split())) + [10 ** 19]

ans = 0
for t1, t2 in zip(T, T[1::]):
  if t2 - t1 < t:
    ans += t2 - t1
  else:
    ans += t
  
print(ans)


Measured memory_bytes: 25196
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>

using namespace std;
using ll = long long;
using ld = long double;

#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);                                     // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))


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

	each(i, e, s)
	{
		if ((ll)'Z' < ((ll)e + n))
			cout << (char)((ll)e + n - (ll)'Z' + 'A' - 1);
		else
			cout << (char)((ll)e + n);
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <set>
using namespace std;
long long fac[200100], finv[200100], inv[200100]; 
long long MOD = 1000000007; 
int MAX = 200100; 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
	int B, W; cin >> B >> W; COMinit();
	long long Black[200100] = {}; 
	long long White[200100] = {}; 
	long long inv2[200100] = {}; 
	inv2[0] = 1; 
	for(int i = 1; i < 200050; i++){
		inv2[i] = inv2[i-1] * inv[2] % MOD; 
	}
	for(int i = B; i < B+W; i++){
		long long tmp = COM(i-1, B-1) * inv2[i] % MOD; 
		Black[i] = (Black[i-1] + tmp) % MOD; 
	}
	for(int i = W; i < B+W; i++){
		long long tmp = COM(i-1, W-1) * inv2[i] % MOD; 
		White[i] = (White[i-1] + tmp) % MOD; 
	}
	for(int i = 0; i < B+W; i++){
		cout << (White[i] + (MOD * 2 + 1 - White[i] - Black[i]) * inv2[1]) % MOD << endl; 
	}
}

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

using namespace std;

long long gcd(long long a, long long b) {
	return (b ? gcd(b, a % b) : a);
}

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

long long Solve(vector<long long> a) {
	int n = (int) a.size();
	long long ret = a[0];
	for(int i = 1; i < n; i++) {
		ret = lcm(ret, a[i]);
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<long long> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cout << Solve(a) << endl;
}

Measured memory_bytes: 3596
import "dart:io";

main(){
  int n = int.parse(stdin.readLineSync());
  List<int> a = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();

  a.sort((x, y) => y - x);
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < n; i++){
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }
  print(alice - bob);
}


Measured memory_bytes: 13120
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int cnt = 0;
  for(int i = 0; i < 3; i++){
    char a;
    cin >> a;
    if(a == 'R'){
      cnt++;
    }
    if(i == 1 && a == 'S' && cnt == 1){
      cout << cnt << endl;
      return 0;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3532
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int ans = 0;
    int i, j;
    int d[100005];
    for (i = 0; i <= n; i++)
        d[i] = 0;
    i = 6;
    while (i<= n)
    {
        d[i] = 1;
        i *= 6;
    }
    i = 9;
    while (i <= n)
    {
        d[i] = 1;
        i *= 9;
    }
    d[1] = 1;
    d[2] = 2;
    for (i = 1; i <= n; i++)
    {
        if (d[i] == 0)
        {
            d[i] = d[i - 1] + 1;;
            for (j = 2; j <= i / 2; j++)
                if (d[i] > (d[j] + d[i - j]))
                    d[i] = d[j] + d[i - j];
        }
    }
    printf("%d\n", d[n]);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;

const ll INF = 5e15;
const ll MOD = 1e9 + 7;

vector<P> V;
ll cnt1 = 0, cnt2 = 0;

void update(ll idx) {
    if (V[idx].second == 0) cnt1++;
    if (V[idx].second == 1) cnt2++;
}

int main() {
    ll ans = 1;
    ll N;
    cin >> N;
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        V.push_back(P(a, 0));
    }
    for (ll i = 0; i < N; i++) {
        ll b;
        cin >> b;
        V.push_back(P(b, 1));
    }
    sort(V.begin(), V.end());
    for (ll i = 0; i < 2 * N; i++) {
        update(i);
        if (cnt1 && cnt2) {
            ans *= max(cnt1, cnt2);
            ans %= MOD;
            cnt1--;
            cnt2--;
        }
    }
    cout << ans << endl;
    return 0;
}


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


#define ll long long


vector<string>v;



void permute(string st)
{
    sort(st.begin() , st.end());


    do{
        v.push_back(st);

    }while(next_permutation(st.begin(),st.end()));
}

double cal(double a[] , double b[] , int x, int y)
{
    double s1 = (a[x]-a[y]) * (a[x]-a[y]);
    double s2 = (b[x]-b[y]) * (b[x]-b[y]);

    return sqrt((s1+s2) * 1.00);
}

int main()
{

    int n;


    string v1;


    cin >> n;


    double a[n] , b[n];

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

    if(n==1)
    {
        v1 = "1";
    }
    else if(n==2)
    {
        v1 = "12";
    }
    else if(n==3)
    {
        v1 = "123";
    }
    else if(n==4)
    {
        v1 = "1234";
    }
    else if(n==5)
    {
        v1 = "12345";
    }
    else if(n==6)
    {
        v1 = "123456";
    }
    else if(n==7)
    {
        v1 = "1234567";
    }
    else if(n==8)
    {
        v1 = "12345678";
    }

    permute(v1);


    long double sum = 0;

    for(int i=0; i<v.size(); i++)
    {
        string s2 = v[i];

       // cout << s2 << endl;

        for(int j=0; j<=s2.size()-2 ; j++)
        {
            int x = s2[j]-'0';

            int y = s2[j+1]-'0';

            sum += cal(a,b,x,y);


        }

    }

    long long sum1 = 1;

    for(int i=1; i<=n; i++)
        sum1 = sum1 * i;

    cout << setprecision(11) << sum/sum1*1.000000 << endl;




    return 0;
}




Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};


int main(){
    string S;
    cin >> S;
    
    reverse(S.begin(), S.end());
    for (int i  = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for (int i  = 0; i < S.size();) {
        bool can2 = false;
        for (int j = 0; j < 4; j++) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
    
}



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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int x;
cin>>x;
cout<< (x>=30 ? "Yes" : "No") <<endl; 
return 0;
}

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

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

    map<ll, int> ma;
    for(int i = 0; i < n; i++){
        ll k;
        cin >> k;
        auto itr = ma.find(k);
        if(itr == ma.end()){
            ma[k] = 1;
        }else{
            ma[k]++;
        }
    }


    auto itr = ma.end();
    while(1){
        if(m == 0){
            break;
        }
        itr = ma.end();
        itr--;
        ll k = itr->first;
        int cou = itr->second;
        ma.erase(k);
        ll t = k / 2;

        if(cou > m){
            auto che = ma.find(t);
            ma[k] = cou - m;
            if(che == ma.end()){
                ma[t] = m;
            }else{
                ma[t] += m;
            }
            m = 0;
        }else{
            auto che = ma.find(t);
            if(che == ma.end()){
                ma[t] = cou;
            }else{
                ma[t] += cou;
            }
            m -= cou;
        }
    }

    ll ans = 0;
    for(auto i = ma.begin(); i != ma.end(); ++i){
        ans += i->first * i->second;
    }

    cout << ans << endl;
}

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

int main() {
    int a, b, degC;
    cin >> a >> b >> degC;

    const double PI = acos(-1);
    const double radC = degC * PI / 180;

    const double h = b * sin(radC);
    const double S = a * h / 2.0;
    const double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(radC));

    printf("%f\n%f\n%f\n",  S, L, h);

    return 0;
}


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf (int)50000000000 //5･10^10
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,sum=0;
  cin>>n;
  int a[n+2];
  a[0]=0,a[n+1]=0;
  rep(i,n) cin>>a[i+1];
  rep(i,n+1) sum+=abs(a[i]-a[i+1]);
  rep(i,n) {
    cout<<sum-(abs(a[i+1]-a[i])+abs(a[i+2]-a[i+1]))+abs(a[i]-a[i+2])<<endl;
  }
}

Measured memory_bytes: 2048
import math

X, K_kai, D = map(int, input().split())

if (abs(X) >= K_kai * D):
    ans = abs(abs(X) - abs(K_kai * D))

else:
    times_low = math.floor(abs(X) / D)
    times_hig = times_low + 1
    
    
    if ((K_kai - times_low) % 2 == 0):
        ans = abs(abs(X) - times_low * abs(D))
            
    else:
        ans = abs(abs(X) - times_hig * abs(D))

print(ans)



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

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define mem(x,i) memset((x),(i),sizeof((x)))
#define odd(x) ((x)&1)
#define LG(x) (int)log2((x))

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ld = long double;

mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int gcd(int aaa,int bbb){
	return (bbb==0 ? aaa : gcd(bbb,aaa%bbb));
}
int lcm(int aaa,int bbb){
	return (aaa/gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**

int n;
int a[1111];
int b[1111];

void solve(){
	cin >> n;
	rep(i,0,n)
		cin >> a[i] >> b[i];
	bool flag = 0;
	rep(i,0,n-2)
		if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2])
			flag = 1;
	cout << (flag ? "Yes\n" : "No\n");
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}


Measured memory_bytes: 3660
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define pli pair<long long , int>
#define pil pair<int ,long long>
#define pi acos(-1)
#define pb push_back
#define mkp make_pair
#define all(a) a.begin(), a.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;


    int h[n];
    int mx = 0;
    int cnt=0;
    for(int i=0;i<n;i++){
        cin>>h[i];
        if(h[i]>=mx){
            cnt++;
            mx=h[i];
        }
    }
    cout<<cnt;
}


Measured memory_bytes: 256
i,j,k;main(n){scanf("%d",&n);double x[n*2],s,t,u,m;s=t=u=m=0;for(;i<n*2;scanf("%lf",&x[i++]));for(;j<n;x[j]=fabs(x[j]-x[n+j++]));for(m=x[0];k<n;s+=x[k],t+=x[k]*x[k],u+=x[k]*x[k]*x[k],m<x[k]?m=x[k]:0,k++);printf("%lf\n%lf\n%lf\n%lf\n",s,sqrt(t),cbrt(u),m);exit(0);}

Measured memory_bytes: 676
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int H, W;
    cin >> H >> W;
    array<array<int, 10>, 10> c;
    rep(i, 0, 10) rep(j, 0, 10) cin >> c[i][j];
    rep(k, 0, 10) rep(i, 0, 10) rep(j, 0, 10) chmin(c[i][j], c[i][k] + c[k][j]);
    int ans = 0;
    int A;
    rep(i, 0, H) rep(j, 0, W)
    {
        cin >> A;
        if (A != -1)
        {
            ans += c[A][1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n][3]{0};
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    int dp[3][n]{0};
    for(int i=0;i<3;i++)
        dp[i][n-1] = a[n-1][i];
    for(int i=n-2;i>=0;i--){
        for(int j=2;j>=0;j--){
            if(j == 2){
                dp[j][i] = a[i][j]+max(dp[j-1][i+1],dp[j-2][i+1]);
            }
            if(j == 1){
                dp[j][i] = a[i][j]+max(dp[j-1][i+1],dp[j+1][i+1]);
            }
            if(j == 0){
                dp[j][i] = a[i][j]+max(dp[j+1][i+1],dp[j+2][i+1]);
            }
        }
    }
    cout<<max(dp[0][0],max(dp[1][0],dp[2][0]))<<"\n";
    return 0;
}

Measured memory_bytes: 2560
N,Y=map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        if Y==10000*i+5000*j+1000*(N-i-j):
            print(i,j,N-i-j)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
//kが奇数ならa,b,cはkで割り切れる
//　　偶数ならa,b,cはk/2で割り切れる
// priority que
//bit全探索
// mod_gcd

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll n,k;
    cin >> n >> k;
    ll cnt1= 0;
    ll cnt2= 0;
    if(k&1){ //奇数
        FOR(i,1,n+1){
            if(i%k==0) cnt1++;
        }
    } else{ //偶数
        FOR(i,1,n+1){
            cnt1 += (i%k == 0);
            cnt2 += (i%k == k/2);
        } 
    }
    cout << cnt1*cnt1*cnt1 + cnt2*cnt2*cnt2 << endl;
}


Measured memory_bytes: 256
import sys
INPUT = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 9)


def main():
    S = INPUT()
    l = len(S)
    ans = 0

    for i in range(2**(l-1)):
        tmp = S[0]
        for j in range(l-1):
            if (i >> j) & 1: tmp += "+"
            tmp += S[j+1]

        ans += eval(tmp)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


int N;
P A[100005], B[100005];
int p[100005];
int main() {
	cin >> N;
	rep(i, N) {
		cin >> A[i].first;
		A[i].second = i;
	}
	rep(i, N) {
		cin >> B[i].first;
		B[i].second = i;
	}
	sort(A, A + N);
	sort(B, B + N);

	rep(i, N) {
		if (A[i].first > B[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}

	rep(i, N) {
		p[A[i].second] = B[i].second;
	}
	int cnt = 0;
	int x = 0;
	do
	{
		x = p[x];
		cnt++;
	} while (x != 0);
	if (cnt != N) {
		cout << "Yes" << endl;
		return 0;
	}
	rep(i, N - 1) {
		if (B[i].first >= A[i+1].first) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    map<i64, i64> dist;
    REP(i, N) {
        i64 a; cin >> a;
        dist[a]++;
    }

    i64 g1 = 0, g2 = 0;
    for (auto &p : dist) {
        if (p.second % 2 == 0) g2++;
        else g1++;
    }

    g1 += (g2 / 2) * 2;
    cout << g1 << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=200000+10;
int tree[maxn*4],ad[maxn*4],L[maxn],R[maxn],id[maxn];
int i,j,k,l,r,t,n,m,ans;
void build(int p,int l,int r){
	if (l==r){
		tree[p]=l;
		return;
	}
	int mid=(l+r)/2;
	build(p*2,l,mid);build(p*2+1,mid+1,r);
	tree[p]=tree[p*2+1];
}
void mark(int p,int v){
	tree[p]+=v;
	ad[p]+=v;
}
void down(int p){
	if (ad[p]){
		mark(p*2,ad[p]);
		mark(p*2+1,ad[p]);
		ad[p]=0;
	}
}
void change(int p,int l,int r,int a,int b){
	if (l==a&&r==b){
		mark(p,1);
		return;
	}
	down(p);
	int mid=(l+r)/2;
	if (b<=mid) change(p*2,l,mid,a,b);
	else if (a>mid) change(p*2+1,mid+1,r,a,b);
	else{
		change(p*2,l,mid,a,mid);
		change(p*2+1,mid+1,r,mid+1,b);
	}
	tree[p]=max(tree[p*2],tree[p*2+1]);
}
int query(int p,int l,int r,int a,int b){
	if (l==a&&r==b) return tree[p];
	down(p);
	int mid=(l+r)/2;
	if (b<=mid) return query(p*2,l,mid,a,b);
	else if (a>mid) return query(p*2+1,mid+1,r,a,b);
	else return max(query(p*2,l,mid,a,mid),query(p*2+1,mid+1,r,mid+1,b));
}
bool cmp(int x,int y){
	return L[x]<L[y];
}
int main(){
	scanf("%d%d",&n,&m);
	build(1,1,m+1);
	fo(i,1,n) scanf("%d%d",&L[i],&R[i]);
	fo(i,1,n) id[i]=i;
	sort(id+1,id+n+1,cmp);
	j=0;
	ans=min(n,m);
	fo(l,0,m){
		while (j<n&&L[id[j+1]]==l){
			j++;
			change(1,1,m+1,1,R[id[j]]);
		}
		ans=min(ans,l+m+n+1-query(1,1,m+1,l+1,m+1));
	}
	printf("%d\n",n-ans);
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,y;
  for(int i=0;i<3000;i++){
  cin>>x>>y;
  if(x==0&&y==0){
    break;
    }
  if(x<y){
    cout<<x<<" "<<y<<endl;
    }else{
    cout<<y<<" "<<x<<endl;
    }
  }
}


Measured memory_bytes: 3076
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
  input! {
    n: usize,
    m: usize,
    h: [i64; n],
    e: [(Usize1, Usize1); m],
  }
  let mut adj = vec![vec![]; n];
  for (a, b) in e.into_iter() {
    adj[a].push(b);
    adj[b].push(a);
  }
  let mut ans = 0;
  for i in 0..n {
    if adj[i].iter().all(|&j| h[i] > h[j]) {
      ans += 1;
    }
  }

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


Measured memory_bytes: 12200
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;
int N, M, C;
int A[21][21];
int B[21];

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

  cin >> N >> M >> C;

  REP(i, M) { cin >> B[i]; }

  REP(i, N) {
    REP(j, M) { cin >> A[i][j]; }
  }

  int ans = 0;
  REP(i, N) {
    int tmp = 0;
    REP(j, M) { tmp += A[i][j] * B[j]; }
    if (tmp + C > 0) ans++;
  }

  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl
#define _GLIBCXX_DEBUG

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

  if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

vector<int> primes;

void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p) prime[i] = false;
        }
    }
    ffor(i,2,n+1) if(prime[i]) primes.pb(i);
    // now only those i are prime if prime[i]=true //
}

int main()
{
	sieve(1000000);
	int x;
	cin>>x;
	cout<<*lb(all(primes),x);
    return 0;
}



Measured memory_bytes: 1916
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] s = new int[n];
    String[] t = new String[n];
    
    for(int i = 0; i < n; i++){
      t[i] = sc.next();
      s[i] = sc.nextInt();
    }
    
    String x = sc.next();
    
    int total = 0;
    
    for(int j = 0; j < n; j++){
      if(x.equals(t[j])){
        for(int k = j+1; k < n; k++){
          total += s[k];
        }
      }
    }
    
    System.out.println(total);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (1LL << 62);
const int MAXN = 100005;
typedef pair<int64_t, int64_t> P;
vector<vector<P>> toa(MAXN), tob(MAXN);

void dijkstra(int64_t start, vector<vector<P>> &Graph, vector<int64_t> &D)
{
  priority_queue<P, vector<P>, greater<P>> PQ;
  vector<int64_t> Color(MAXN, 0);

  D.at(start) = 0;
  PQ.push(make_pair(0, start));
  Color.at(start) = 1;

  while (!PQ.empty())
  {
    auto f = PQ.top();
    PQ.pop();
    int64_t u = f.second;
    Color.at(u) = 2;
    if (D.at(u) < f.first)
      continue;
    for (int i = 0; i < Graph.at(u).size(); i++)
    {
      int64_t v = Graph.at(u).at(i).first;
      if (Color.at(v) == 2)
        continue;
      if (D.at(v) > D.at(u) + Graph.at(u).at(i).second)
      {
        D.at(v) = D.at(u) + Graph.at(u).at(i).second;
        PQ.push(make_pair(D.at(v), v));
        Color.at(v) = 1;
      }
    }
  }
}

int main()
{
  int64_t N, M, S, T, u, v, a, b;
  cin >> N >> M >> S >> T;
  S--, T--;
  for (int i = 0; i < M; i++)
  {
    cin >> u >> v >> a >> b;
    u--, v--;
    toa[u].emplace_back(v, a);
    toa[v].emplace_back(u, a);
    tob[u].emplace_back(v, b);
    tob[v].emplace_back(u, b);
  }
  vector<int64_t> d1(MAXN, INF), d2(MAXN, INF);
  dijkstra(S, toa, d1);
  dijkstra(T, tob, d2);
  priority_queue<P> pq;
  int64_t init = 1000000000000000;
  for (int i = 0; i < N; i++)
  {
    int64_t cost = init - d1[i] - d2[i];
    pq.emplace(cost, i);
  }
  for (int i = 0; i < N; i++)
  {
    while (pq.top().second < i)
    {
      pq.pop();
    }
    cout << pq.top().first << endl;
  }
}


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

int main(void){
    double n, m;
    std::cin >> n >> m;
    double sum = 0;
    std::vector<double> a(n);

    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        sum += a[i];
    }
    //std::cout << sum << std::endl;
    double border = sum * 1 / 4 / m;

    std::sort(a.rbegin(), a.rend());
    /*
    for(auto i : a){
        std::cout << i << " ";
    }
    */
    std::cout << std::endl;
    if( a[m-1] >= border ){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }



/*
   for(int i = 0; i < n; i++){
        std::cin >> a[i];
        sum += a[i];
    }

    int cnt = 0;
    double border = sum * 1 / 4 / m;

    for(int i = 0; i < n; i++){
        if(a[i] < border){
            
        }else{
            cnt++;
        }
    }
    
    if(cnt >= m){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    */
    return 0;
}

Measured memory_bytes: 256