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

using namespace std;
int main() {
  int N;
  cin >> N;
  int nums[N]; 
  priority_queue<int> lis; 
  int count[200005]; 
  memset(count,0,sizeof(count));   
  for(int i = 0; i < N; i++){
    cin >> nums[i]; 
    lis.push(nums[i]); 
    count[nums[i]]++; 
  }
  int temp; 
  for(int i = 0; i < N; i++){
    if (nums[i] != lis.top()){
      cout << lis.top(); 
    } else {
      if (count[lis.top()] > 1){
        cout << lis.top(); 
      } else {
        temp = lis.top(); 
        lis.pop();
        cout << lis.top();
        lis.push(temp); 
      }
    }
    cout << endl; 
  }
    
}


Measured memory_bytes: 4084
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

unordered_set<int> prim(int N) {
    int x = 2;
    unordered_set<int> ans;
    REP(i, 1, N) ans.insert(i + 1);
    for (int i = 2; i * i <= N; i++) {
        int t = 2;
        while (1) {
            if (ans.find(i * t) != ans.end()) {
                ans.erase(i * t);
                
            }
            t++;
            if (i * t > N) break;
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    auto prims = prim(55555);
    vint ans(N);
    int i = 0;
    for (auto& p : prims) {
        if ((p - 1) % 5 == 0) {
            if (i >= N) break;
            ans[i] = p;
            i++;
        }
    }
    rep(i, N) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2444
def resolve():
    N, T = list(map(int, input().split()))
    CT = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0])
    for cost, time in CT:
        if time > T:
            continue
        print(cost)
        break
    else:
        print("TLE")



if '__main__' == __name__:
    resolve()

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n;
  vector<ll>a;
  ll ma=0;
  while(cin>>n){
    if(n==0)break;
    chmax(ma,n);
    a.push_back(n);
  }
  vector<ll>v;
  rep(i,1,190)v.push_back(i*(i+1)*(i+2)/6);
  // out(v[4]);
  // out(v[v.size()-1]);
  ma++;

  ll dp[ma];fill(dp,dp+ma,INF);
  dp[0]=0;
  rep(i,1,ma){
    dp[i]=dp[i-1]+1;
    rep(j,1,v.size()){
      if(i-v[j]>=0)chmin(dp[i],dp[i-v[j]]+1);
    }
  }

  ll d[ma];fill(d,d+ma,INF);
  d[0]=0;
  rep(i,1,ma){
    d[i]=d[i-1]+1;
    rep(j,1,v.size()){
      if(v[j]%2==0)continue;
      if(i-v[j]>=0)chmin(d[i],d[i-v[j]]+1);
    }
  }
  rep(i,0,a.size()){
    out(dp[a[i]]<<" "<<d[a[i]]);
  }




  return 0;
}



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

int main() {
  string a;
  cin>>a;
  int count=0;
  int answer=0;
  
  for(int i=0;i<a.size();i++){
    if(a.at(i)=='A'){
    count++;
    }
    if(a.at(i)=='C'){
    count++;
    }
    if(a.at(i)=='G'){
    count++;
    }
    if(a.at(i)=='T'){
    count++;
    }
    answer=max(answer,count);
    if(a.at(i)!='A'&&a.at(i)!='C'&&a.at(i)!='G'&&a.at(i)!='T'){
      count=0;
    }
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    #include<math.h>
    #define MaxN 200000+100 
    typedef long long LL;
    int a[MaxN];
    int b[MaxN];
    int main()
    {
    	int Q;
    	scanf("%d",&Q);
    	LL sum=0; 
    	LL min=1e18+7;
    	int flag=0;
    	for(int i=0;i<Q;i++)
    	{
    		LL a,b;
    		scanf("%lld %lld",&a,&b);
    		sum+=a; 
    		if(a!=b)
    			flag=1;
    		if(a>b)
    			min=min<b?min:b;
    	}
    	if(!flag)
    		printf("0");
    	else
    		printf("%lld\n",sum-min);
    	return 0;
     } 

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

plus = [i+a for i, a in enumerate(As)]
minus = [i-a for i, a in enumerate(As)]
from collections import Counter

pc = Counter(plus)
mc = Counter(minus)
ans = 0
for p, cnt in pc.most_common():
    ans += cnt*mc[p]
print(ans)

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

int main() {
    int N;
    cin >> N;
    int res = 0;
    int c = 0, d = 0, e = 0;
    for(int i=0; i<N; ++i) {
        string s;
        cin >> s;
        if(s[0] == 'B') ++c;
        if(s[s.size()-1] == 'A') ++d;
        if(s[0] == 'B' && s[s.size()-1] == 'A') ++e;

        for(int j=0; j+1<s.size(); ++j) {
            if(s[j] == 'A' && s[j + 1] == 'B') ++res;
        }
    }
    
    if(c - e > 0 && d - e > 0) {
        if(e > 0) res += e + 1 + min(c - e - 1, d - e - 1);
        else res += min(c, d);
    } else if(e > 0 && (c - e > 0 || d - e > 0)) {
        res += e;
    } else {
        res += max(e - 1, 0);
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#N = int(input())
#N = int(input())
#S = input()
# = input().split()
# = input().split()
# = map(int,input().split())
X,N = map(int,input().split())
if N != 0:
    p = list(map(int,input().split()))
else:
    print(X)
    exit()
# = list(map(int,input()).split())
i = 0
while True:
    if X-i not in p:
        print(X-i)
        exit()
    if X + i not in p:
        print(X+i)
        exit()
    i += 1

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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse);

            var a = input.ElementAt(0);
            var b = input.ElementAt(1);

            if (b % a == 0)
            {
                Console.WriteLine(a + b);
            }
            else
            {
                Console.WriteLine(b - a);
            }
        }
    }
}


Measured memory_bytes: 11220
# https://atcoder.jp/contests/abc123/tasks/abc123_b


A = gets.to_i
B = gets.to_i
C = gets.to_i
D = gets.to_i
E = gets.to_i

vs = [A, B, C, D, E];

ans = 0
last = [10, -1]
vs.each do |v|
  q, r = (v + 9).divmod(10)
  add = q * 10
  if r < last[0]
    last = [r, add - v]
  end
  ans += add
end
ans = ans - last[1]

puts ans


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

#define B 500000
#define INF 0x7ffffffffffff
#define SZ (B*2+10)
using LLI = long long int;
using Pair = pair<LLI, int>;

int N;
LLI P;
LLI Q;
LLI cs[514514];
priority_queue<Pair> q;

int main() {
  scanf("%d%lld%lld", &N, &P, &Q);

  LLI ans = 0;
  for (int i=0; i<N; i++) {
    scanf("%lld", &cs[i]);
    LLI t = P*(Q+i) + 2*P*(N-1-i);
    q.push(Pair(cs[i]-t, i));
    ans += P*(Q+i);
  }

  LLI cnt = 0;
  LLI pool = 0;
  while (!q.empty()) {
    Pair p = q.top(); q.pop();
    LLI t = p.first + cnt*P*2;
    ++cnt;
    if (pool+t < 0) {
      pool += t;
      continue;
    }

    ans += pool+t;
    pool = 0;
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 14752
#include<vector>
#include<iostream>
int main(){
    int N,K;
    std::cin>>N>>K;
    std::vector<unsigned int> A=std::vector<unsigned int>(N);
    for(int i=0;i<N;++i){
        std::cin>>A[i];
    }
    for(int i=0;i+K<N;++i){
        if(A[i]<A[i+K]){
            std::cout<<"Yes"<<std::endl;
        }else{
            std::cout<<"No"<<std::endl;
        }
    }
}

Measured memory_bytes: 4012
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

cnt=0
k=int(input())
#111
for i in range(1,k+1):
  #print(i,i,i)
  cnt+=gcd(i,i,i)
#112,121,211
for a in range(1,k):
  for b in range(a+1,k+1):
    #print(a,a,b)
    cnt+=gcd(a,a,b)*3
#221,212,122
for a in range(1,k):
  for b in range(a+1,k+1):
    #print(a,b,b)
    cnt+=gcd(a,b,b)*3
#123
for a in range(1,k-1):
  for b in range(a+1,k):
    for c in range(b+1,k+1):
      #print(a,b,c)
      cnt+=gcd(a, b, c)*6
print(cnt)

Measured memory_bytes: 9652
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;
using namespace std;

const ll mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    pair<ll, ll> jobs[n];
    for (int i = 0; i < n; i++) {
        ll a, b; cin >> a >> b;
        jobs[i] = { b, a };
    }
    sort(jobs, jobs + n);
    ll cur = 0;
    for (int i = 0; i < n; i++) {
        pair<ll, ll> job = jobs[i];
        if (cur + job.second > job.first) {
            puts("No");
            return 0;
        }
        cur += job.second;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  char a;
  cin>>a;
  cout<<(a>='a'?'a':'A')<<endl;
  return 0;
}


Measured memory_bytes: 3616
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

manzoku = 0
before = -10
for i in A:
    i = i-1
    manzoku += B[i]
    if before+1 == i:
        manzoku +=C[i-1]
    before = i
print(manzoku)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;

int t[10000][2],m=0;
string d;

int main(){
    while(getline(cin,d)){
	if(d.size()==0)m++;
	if(m==2)break;
	int cur=0,n=0;
	while(cur<d.size()){
	    if(isdigit(d[cur])){n=n*10+d[cur]-'0';cur++;}
	    else break;
	}
	t[n][m]++;
    }
    for(int i=0;i<10000;i++)if(t[i][0]&&t[i][1])cout<<i<<" "<<t[i][0]+t[i][1]<<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> &a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
template<class T>void prArr(T a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


class UF{
public:
  Int V;
  vector<Int> par,rnk,sz;
  UF(){}
  UF(Int V):V(V),par(V),rnk(V,0),sz(V,1){for(Int i=0;i<V;i++)par[i]=i;}
  
  Int find(Int x){
    assert(x < V);
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(Int x,Int y){
    x=find(x), y=find(y);
    if(x==y)return;
    if(rnk[x]<rnk[y])par[x]=y, sz[y] += sz[x];
    else{
      par[y]=x;
      sz[x] += sz[y];
      if(rnk[x]==rnk[y])rnk[x]++;
    }
  }

  bool same(Int x,Int y){return find(x)==find(y);}

  Int size(Int x){return sz[find(x)];}
};


Int N;
string A;
vector<vector<Int> > G;

const Int M = 200011;
Int used[M][2],ans = 0;
void dfs(Int pos, Int cnt, Int num,char target){
  ans |= (cnt == 0 && used[pos][cnt] == num);
  if(used[pos][cnt] != 0) return;
  if(ans) return;
  
  used[pos][cnt]  = num;
  for(Int to:G[pos]){
    if(cnt == 0 && A[to] != A[pos]) continue;
    if(cnt == 1 && A[to] == A[pos]) continue;
    dfs(to, cnt ^ 1, num, target);
  }
  used[pos][cnt] = -1;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int M;
  cin>>N>>M;
  cin>>A;
  G.resize(N);

  for(Int i=0;i<M;i++){
    Int a, b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  for(Int i=0;i<N;i++) {
    if(A[i] == 'B') dfs(i, 0, i+1, 'B');
  }
  dfs(0, 1, 1, 'B');
  cout<<(ans? "Yes":"No")<<endl;
  
  return 0;
}


Measured memory_bytes: 18128
#include <stdio.h>
#include <vector>
using namespace std;
#define N (100010)
vector<int> v[N];
int s[N], lst[N], nxt[N];
int n; 
int dfs(int fa, int x){
    int ok = 0;
    for (auto i = v[x].begin(); i != v[x].end(); ++i){
        if (*i != fa){
            if (dfs(x, *i)) nxt[x] = *i, ok = 1;
            s[x] += s[*i];
        }
    }
    s[x]++;
    return x == n || ok == 1;
}
int main(){
    scanf("%d", &n);
    for (int a, b, i = 1; i < n; i++){
        scanf("%d%d", &a, &b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(0, 1);
    lst[0] = 1;
    int len = 0;
    for (int i = 1; i <= n; i++){
        lst[i] = nxt[lst[i - 1]];
        if (lst[i] == n){
            len = i;
            break;
        }
    }
    int b = s[lst[len / 2 + 1]];
    int a = n - b;
    if (a > b){
        printf("Fennec\n");
    }
    else {
        printf("Snuke\n");
    }
}

Measured memory_bytes: 13184
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   int n,k,h;
   cin >> n >> k;
   int count=0;
   REP(i,n){
      cin >> h;
      if(h >= k) count++;
   }
   
   cout << count << endl;
   
   
   return 0;
}

Measured memory_bytes: 256
from collections import deque
 
N = int(input())
# commands = [input().split() for i in range(N)]
 
doubly_linked_list = deque()
for i in range(N):
    commands = input().split()
    command = commands[0]
    if len(commands) == 2:
        key = commands[1]
        if command[0] == 'd':
            try :
                doubly_linked_list.remove(key)
                continue
            except:
                continue
        else: 
            doubly_linked_list.appendleft(key)
            continue
    else :
        if command[6] == 'F':
            doubly_linked_list.popleft()
            continue
        else:
            doubly_linked_list.pop()
            continue
 
    # print(doubly_linked_list)
# print(doubly_linked_list)
print(' '.join(doubly_linked_list))


Measured memory_bytes: 69736
#include <iostream>
#include <string>
#include <array>
#include <bitset>
#include <cstdint>

int main()
{
	enum { Left, Up, Right, Down };

	typedef std::array<std::bitset<4>, 5> Row;
	typedef std::array<Row, 5> Matrix;
	Matrix matrix;
	for (auto& row : matrix) {
		row.fill(std::bitset<4>());
	}

	std::string input;
	std::getline(std::cin, input);
	for (std::uint16_t x = 0; x < 4U; ++x) {
		if (input[x] == '1') {
			matrix[0][x].set(Right);
			matrix[0][x + 1].set(Left);
		}
	}

	for (std::uint16_t y = 0; y < 4U; ++y) {
		std::getline(std::cin, input);
		for (std::uint16_t x = 0; x < 5U; ++x) {
			if (input[x] == '1') {
				matrix[y][x].set(Down);
				matrix[y + 1][x].set(Up);
			}
		}
		std::getline(std::cin, input);
		for (std::uint16_t x = 0; x < 4U; ++x) {
			if (input[x] == '1') {
				matrix[y + 1][x].set(Right);
				matrix[y + 1][x + 1].set(Left);
			}
		}
	}

	std::uint16_t y = 0, x = 0;
	char direct = 'R';
	do {
		if (direct == 'R') {
			if (matrix[y][x][Up]) {
				direct = 'U';
				--y;
			}
			else if (matrix[y][x][Right]) {
				direct = 'R';
				++x;
			}
			else if (matrix[y][x][Down]) {
				direct = 'D';
				++y;
			}
			else {
				direct = 'L';
				--x;
			}
		}
		else if (direct == 'D') {
			if (matrix[y][x][Right]) {
				direct = 'R';
				++x;
			}
			else if (matrix[y][x][Down]) {
				direct = 'D';
				++y;
			}
			else if (matrix[y][x][Left]) {
				direct = 'L';
				--x;
			}
			else {
				direct = 'U';
				--y;
			}
		}
		else if (direct == 'L') {
			if (matrix[y][x][Down]) {
				direct = 'D';
				++y;
			}
			else if (matrix[y][x][Left]) {
				direct = 'L';
				--x;
			}
			else if (matrix[y][x][Up]) {
				direct = 'U';
				--y;
			}
			else {
				direct = 'R';
				++x;
			}
		}
		else if (direct == 'U') {
			if (matrix[y][x][Left]) {
				direct = 'L';
				--x;
			}
			else if (matrix[y][x][Up]) {
				direct = 'U';
				--y;
			}
			else if (matrix[y][x][Right]) {
				direct = 'R';
				++x;
			}
			else {
				direct = 'D';
				++y;
			}
		}
		std::cout << direct << std::flush;
	} while (not (y == 0 and x == 0));
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
typedef pair<double,int> pdi;

int n;
vector<int> bit;

void update(int k,int a){
	while(k<=n){
		bit[k]+=a;
		k=(k|(k-1))+1;
	}
}

int s(int k){
	int r=0;
	while(k>0){
		r+=bit[k];
		k=k&(k-1);
	}
	return r;
}

struct line{
	double a,b,c;
};

bool cmp(line l,line m){//lの傾き>mの傾き
	return (l.a/l.b)<(m.a/m.b);
}

const double inf=200000001;
line l[40000];

bool cmpfi(pdi p,pdi q){
	return p.fi<q.fi;
}

bool cmpsc(pdi p,pdi q){
	return p.sc<q.sc;
}

int main(){
	scanf("%d",&n);
	int m=(n*(n-1))/2;
	if(m%2==0){
		m/=2;
		m-=1;
	}else m/=2;
	for(int i=0;i<n;++i) scanf("%lf%lf%lf",&l[i].a,&l[i].b,&l[i].c);
	sort(l,l+n,cmp);
	vector<pdi> v(n);
	for(int i=0;i<n;++i) v[i].sc=i;
	bit.resize(n+1);
	double ub=inf,lb=-inf;
	for(int cnt=0;cnt<60;++cnt){
		double mid=(ub+lb)/2;
		for(int i=0;i<n;++i) v[i].fi=(l[i].c-(l[i].a*mid))/l[i].b;
		sort(v.begin(),v.end(),cmpfi);
		for(int i=0;i<n;++i) v[i].fi=i;
		sort(v.begin(),v.end(),cmpsc);
		int c=0;
		fill(bit.begin(),bit.end(),0);
		for(int i=0;i<n;++i){
			c+=s(n-v[i].fi);
			update(n-v[i].fi,1);
		}
		if(c<=m) lb=mid;
		else ub=mid;
	}
	printf("%.10lf ",ub);
	for(int i=0;i<n;++i) swap(l[i].a,l[i].b);
	sort(l,l+n,cmp);
	for(int i=0;i<n;++i) v[i].sc=i;
	ub=inf,lb=-inf;
	for(int cnt=0;cnt<60;++cnt){
		double mid=(ub+lb)/2;
		for(int i=0;i<n;++i) v[i].fi=(l[i].c-(l[i].a*mid))/l[i].b;
		sort(v.begin(),v.end(),cmpfi);
		for(int i=0;i<n;++i) v[i].fi=i;
		sort(v.begin(),v.end(),cmpsc);
		int c=0;
		fill(bit.begin(),bit.end(),0);
		for(int i=0;i<n;++i){
			c+=s(n-v[i].fi);
			update(n-v[i].fi,1);
		}
		if(c<=m) lb=mid;
		else ub=mid;
	}
	printf("%.10lf\n",ub);
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    long n,r;
    cin>>n>>r;
    if(n<=10)
    {
        cout<<100*(10-n)+r<<endl;
    }
    else
    {
        cout<<r<<endl;
    }
    return 0;
}



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

#define MAX 31
#define INF (1<<30)
int W, H, d[MAX][MAX], T[MAX][MAX], Y[MAX][MAX];

void bfs(){
    queue<pair<int, int> > todo;
    todo.push(make_pair(0, 0));
    while(!todo.empty()){
        int x = todo.front().first, y = todo.front().second;
        todo.pop();
        if(!Y[x][y] && d[x - 1][y] == INF){
            d[x - 1][y] = d[x][y] + 1;
            todo.push(make_pair(x - 1, y));
        }
        if(!T[x][y] && d[x][y - 1] == INF){
            d[x][y - 1] = d[x][y] + 1;
            todo.push(make_pair(x, y - 1));
        }
        if(!Y[x + 1][y] && d[x + 1][y] == INF){
            d[x + 1][y] = d[x][y] + 1;
            todo.push(make_pair(x + 1, y));
        }
        if(!T[x][y + 1] && d[x][y + 1] == INF){
            d[x][y + 1] = d[x][y] + 1;
            todo.push(make_pair(x, y + 1));
        }
    }
    return;
}

int main(){
    while(cin >> W){
        if(W == 0) return 0;
        cin >> H;
        for(int i = 0; i < H; i++) for(int j = 0; j < W; j++) d[i][j] = INF;
        d[0][0] = 1;
        for(int i = 0; i < H; i++) T[i][0] = T[i][W] = 1;
        for(int i = 0; i < W; i++) Y[0][i] = Y[H][i] = 1;
        for(int i = 0; i < H; i++){
            if(i) for(int j = 0; j < W; j++) cin >> Y[i][j];
            for(int j = 1; j < W; j++) cin >> T[i][j];
        } 
        bfs();
        cout << (d[H - 1][W - 1] == INF ? 0 : d[H - 1][W - 1]) << endl;
    }
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

ll n;
ll dp[105][4][4][4];
//A-0, G-1, C-2, T-3.
ll rec(int pos, int d1, int d2, int d3){
    if(pos >= n){
        if(d1 == 0 && d2 == 1 && d3 == 2) return 0;
        return 1;
    }
    if(d1 == 0 && d2 == 1 && d3 == 2) return 0;
    ll &ans = dp[pos][d1][d2][d3];
    if(ans != -1) return ans;
    ans = 0;
    int k1 = d2, k2 = d3, k3;
    f(i, 4){
        if(d1 == 0 && d2 == 1 && i == 2) continue;
        if(d2 == 0 && d3 == 1 && i == 2) continue;
        if(d2 == 0 && d3 == 2 && i == 1) continue;
        if(d2 == 1 && d3 == 0 && i == 2) continue;
        if(d1 == 0 && d3 == 1 && i == 2) continue;
        k3 = i;
        ans = add(ans, rec(pos + 1, k1, k2, k3));
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>n;
    f(i, 105) f(j, 4) f(k, 4) f(l, 4) dp[i][j][k][l] = -1;
    cout<<rec(0, 3, 3, 3);
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

res = []
for i in range(m-1):
  res.append(x[i+1]-x[i])
res.sort()

ans = 0
for i in range(m-n):
  ans += res[i]
print(ans)

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


int main(){
    int N, K, Q, p;
    cin >> N >> K >> Q;
    vector<int> P(N);
    for (int i = 0; i < Q; i++) {
        cin >> p;
        P.at(p-1) += 1;
    }
    for (int i = 0; i < N; i++)
        cout << (P.at(i) + K - Q >= 1 ? "Yes" : "No") << endl;
    return 0;  
}


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

int main(void) {
    int n, k;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    cout << k * (int)pow((k - 1), (n - 1)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, M, X, A[110], count0 = 0, countN = 0;
	scanf("%d%d%d", &N, &M, &X);
	for (int i = 0; i < M; i++) {
		scanf("%d", &A[i]);
		if (A[i] < X) {
			count0++;
		}
		else {
			countN++;
		}
	}
	if (count0 >= countN) {
		printf("%d", countN);
	}
	else {
		printf("%d", count0);
	}
	return 0;
}

Measured memory_bytes: 128
S = input()
countList = []
alphabetList = []
for i in range(ord("a"),ord("z")+1):
    alphabetList.append(chr(i))
    countList.append(S.count(chr(i)))
if min(countList) != 0:
    print("None")
else:
    print(alphabetList[countList.index(0)])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int a,b,c;
  while(cin >> a >> b >> c){
    cout << (a+b+c >= 22 ? "bust" : "win") << endl;
  }

  return 0;
}


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

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

    int N, T;
    cin >> N >> T;

    int mini = 1e9;
    for(int i = 0; i < N; i++){
        int c, t;
        cin >> c >> t;
        if(t <= T){
            mini = min(mini, c);
        }
    }

    if(mini == 1e9){
        cout << "TLE" << endl;
    }else{
        cout << mini << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int n = s.size();
 
  int ans = 0;
  for(int i=0;i<n;i++){
    if(s[i] == 'O'){
      int j = 0;
      while( (i+j<n) && (s[i+j] == 'O') )j++;
       
      int k = 0;
      while( (0<=i-1-k) && (k<j) && (s[i-1-k] == 'J'))k++;
       
      int l = 0;
      while( (i+j+l<n) && (l<j) && (s[i+j+l] == 'I'))l++;
 
      if(j==k && j==l)ans = max(ans,j);
 
      i += j+l-1;
    }
  }
  cout << ans << endl;
}
 

Measured memory_bytes: 1984
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,k;
  cin>>m>>k;
  if(k==0){
    cout<<"0";
    for(int i=1;i<(1<<m);++i)cout<<" "<<i;
    for(int i=(1<<m)-1;i>=0;--i)cout<<" "<<i;
  }
  else if(m>1&&k<(1<<m)){
    cout<<"0";
    for(int i=1;i<(1<<m);++i)if(i!=k)cout<<" "<<i;
    cout<<" 0 "<<k;
    for(int i=(1<<m)-1;i>=1;--i)if(i!=k)cout<<" "<<i;
    cout<<" "<<k<<endl;
  }
  else cout<<"-1\n";
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

typedef long long ll;
ll n, m;
int main(){
	cin >> n >> m;
	ll x=0;
	for(ll i = 0; i<n; i++){
		ll a; cin >> a;
		x += a*(n-2*i-1);
		x %= mod; x += mod; x %= mod;
	}
	ll y=0;
	for(ll i = 0; i<m; i++){
		ll a; cin >> a;
		y += a*(m-2*i-1);
		y %= mod; y += mod; y %= mod;
	}
	cout << (x*y)%mod;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    string s; cin >> s;

    string ans;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0' || s[i] == '1') {
            ans += s[i];
        } else if (ans.size() > 0) {
            ans.erase(ans.end()-1);
        } 
    }

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


Measured memory_bytes: 256
import bisect
from collections import defaultdict

N = int(input())
S = list(input())
Q = int(input())

alpha_dic = defaultdict(list)

for i, s in enumerate(S):
    alpha_dic[s].append(i)

for _ in range(Q):
    l, m, n = input().split()

    if l == '1':
        m = int(m) - 1
        c = S[m]

        if c == n:
            continue
        else:
            i = bisect.bisect_left(alpha_dic[c], m)
            del alpha_dic[c][i]

            bisect.insort_left(alpha_dic[n], m)
            S[m] = n
    else:
        m, n = int(m) - 1, int(n) - 1

        cnt = 0
        for _, val in alpha_dic.items():
            if not val:
                continue

            left_idx = bisect.bisect_left(val, m)
            right_idx = bisect.bisect_left(val, n)
            l = len(val)

            if left_idx > right_idx or (left_idx == right_idx and left_idx == l) or (left_idx == right_idx and val[left_idx] != m and val[right_idx] != n):
                continue

            cnt += 1

        print(cnt)


Measured memory_bytes: 30728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int x = scan.nextInt();
		String message = "NO";
		if(a <= x && x <= a + b) {
			message = "YES";
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 22100
n,q = map(int,input().split())
s = input()
a = [0]*n
for i in range(n):
    if s[i] == 'C' and i >= 1 and s[i-1] =='A':
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]
for __ in range(q):
    l,r = map(int,input().split())
    r-=1
    l-=1
    ans = int()
    if l >=1:
        ans = a[r]-a[l-1]
        if s[l] == 'C' and s[l-1] == 'A':
            ans-=1
    else:
        ans = a[r]
    print(ans)

Measured memory_bytes: 7596
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;


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

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

int main()
{
    int N, D;
    cin >> N >> D;
    int ans = 1;
    while(2 * D * ans + ans < N){
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,D[200001],mod=998244353;
    cin>>n;
    rep(i,n) cin>>D[i];
    if(D[0]!=0){
        cout<<0;
        return 0;
    }
    sort(D,D+n);
    if(D[1]==0){
        cout<<0;
        return 0;
    }
    ll ans=1,num[200001]={0},m=0;
    rep(i,n){
        num[D[i]]++;
        m=max(m,D[i]);
    }
    rep(i,m){
        if(num[i+1]==0){
            cout<<0;
            return 0;
        }
    }
    rep(i,n-1){
        ans=ans*num[D[i+1]-1]%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  A--, B--, C--, D--;
  string S;
  cin >> S;
  bool ok = true;
  // ##が含まれてたらNG
  for (int i = A; i + 1 <= C; ++i) {
    if (S[i] == '#' && S[i + 1] == '#') ok = false;
  }
  for (int i = B; i + 1 <= D; ++i) {
    if (S[i] == '#' && S[i + 1] == '#') ok = false;
  }
  // C > D の場合は B ~ D の間に...が含まれているかを確認する必要がある
  // ...が含まれていればすぬけ君がふぬけ君を追い抜かせる
  if (C > D) {
    bool over = false;
    for (int i = B; i <= D; ++i) {
      if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
        over = true;
        break;
      }
    }
    ok = over;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;
  ll onenum = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '1') {
      onenum++;
    }
  }
  ll d[3][N];
  d[0][0] = 1;
  d[1][0] = 1;
  d[2][0] = 1;

  if (onenum == 1) {
    for (ll i = 2; i < 3; i++) {
      ll a = 1;
      for (ll j = 1; j < N; j++) {
        a *= 2;
        a %= (onenum + i - 1);
        d[i][j] = a; 
      }
    }
    
    ll sum4 = 0;
    for (ll i = N-1; i >= 0; i--) {
      if (S[(N-1)-i] == '1') {
        
        sum4 += d[2][i]; 
      }
      sum4 %= onenum + 1;
    }
    for (ll i = 0; i < N; i++) {
      ll s;
      if (S[i] == '1') {
        s = 0;
        cout << 0 << endl;
        continue;
      } else {
        s = (sum4 + d[2][N-1-i]) % (onenum + 1);
      }
      ll cnt = 1;
      while (s != 0) {
        int e = __builtin_popcount(s);
        s = s % e;
        cnt++;
      }
      cout << cnt << endl;
    }
    return 0;
  }
  if (onenum == 0) {
    for (ll i = 0; i < N; i++) {
      cout << 1 << endl;
    }
    return 0;  
  }
  for (ll i = 0; i < 3; i++) {
    ll a = 1;
    for (ll j = 1; j < N; j++) {
      a *= 2;
      a %= (onenum + i - 1);
      d[i][j] = a; 
    }
  }
  ll sum1_ = 0;
  ll sum2_ = 0;
  ll sum3_ = 0;
  for (ll i = N-1; i >= 0; i--) {
    if (S[(N-1)-i] == '1') {
      sum1_ += d[0][i];
      sum2_ += d[1][i];
      sum3_ += d[2][i]; 
    }
    sum1_ %= onenum - 1;
    sum2_ %= onenum;
    sum3_ %= onenum + 1;
  }
  for (ll i = 0; i < N; i++) {
    ll s;
    if (S[i] == '1') {
      s = (sum1_ - d[0][N-1-i]) % (onenum - 1);
      if (s < 0) {
        s += (onenum - 1);
      }
    } else {
      s = (sum3_ + d[2][N-1-i]) % (onenum + 1);
    }
    ll cnt = 1;
    while (s != 0) {
      int e = __builtin_popcount(s);
      s = s % e;
      cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dist(int x, int y){
  return min(abs(x-y), 24-abs(x-y));
}

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

  int N;
  cin >> N;
  VI cnt(13);
  REP(i,N){
	int x;
	cin >> x;
	cnt[x]++;
  }
  if(cnt[0] || cnt[12] > 1){
	cout << 0 << endl;
	return 0;
  }

  VI ds = {0};
  if(cnt[12]) ds.PB(12);
  VI unds;
  REP(i,12){
	if(cnt[i] == 0) continue;
	if(cnt[i] == 1){
	  unds.PB(i);
	}
	else if(cnt[i] == 2){
	  ds.PB(i);
	  ds.PB(24-i);
	}
	else{
	  cout << 0 << endl;
	  return 0;
	}
  }

  int M = SZ(unds);
  int ans = 0;
  for(int b=0;b<(1<<M);++b){
	VI tmp = ds;
	REP(i,M){
	  if(b>>i&1){
		tmp.PB(unds[i]);
	  }
	  else{
		tmp.PB(24 - unds[i]);
	  }
	}

	int bet = 100;
	REP(i,SZ(tmp)) REP(j,i){
	  mini(bet, dist(tmp[i], tmp[j]));
	}
	maxi(ans, bet);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N,M,Q;
    int x[505][505];
    int c[505][505];
    cin >> M >> M >> Q;
    
    for(int i=0;i<M;i++){
        int l,r;
        cin >> l >> r;
        x[l][r]++;
    }
    
    for(int i=1;i<=500;i++){
        for(int j=1;j<=500;j++){
            c[i][j] = c[i][j-1] + x[i][j];
        }
    }

    for(int i=0;i<Q;i++){
        int p,q;
        int ans = 0;
        cin >> p >> q;
        for(int j=p;j<=q;j++){
            ans += c[j][q]-c[j][p-1];
        }
        cout << ans << endl;
    }

    
}


Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int alp[26];
int main(){
  string s;cin>>s;
  for(int i = 0; s.size() > i; i++){
    alp[s[i]-'a']++;
  }
  for(int i = 0; 26 > i; i++){
    if(!alp[i]){
      cout << (char)('a'+i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
def main():
    x, y, a, b, c = map(int, input().split())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))

    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)
    p = p[:x]
    q = q[:y]
    ans = p+q
    ans.sort()
    now = 0
    for i in range(x+y):
        if r[now] > ans[i]:
            ans[i] = r[now]
            now += 1
            if now == c:
                break
    print(sum(ans))


main()

Measured memory_bytes: 23216
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T,U;
  int A,B;
  cin >> S >> T >> A >> B >> U;
  if (S == U){
    cout << A - 1 << ' ' << B;
  } else {
    cout << A << ' ' << B - 1;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;
void solve(){
	cout     << "\n";
}

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

	int x[1000001] = {0};
	int n,q;
	cin >>n >> q;

	int max_now=0;
	int now_id = 1;


	for(int i=0;i<q;i++){
		int a ,v;
		cin >>a >> v;
		x[a-1] += v;

		if(v >0 && (x[a-1] > max_now || x[a-1]==max_now && now_id >a )){
			max_now = x[a-1];
			now_id = a;
		}else if(v<0 && now_id == a){
			max_now=0;
			now_id = 1;
			for(int j = 0;j<n;j++){
				if(x[j]>max_now){
					max_now=x[j];
					now_id = j+1;
				}
			}


		}
			cout << now_id <<" " << max_now << "\n";
	}

		
		
	/*
	while(cin >>){
	solve();	
	}
	*/
	return 0;
}

Measured memory_bytes: 5116
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define clr(a, b) memset((a), (b), sizeof(a))
#define debugs(x) cout << "Line" << __LINE__ << "	" << #x << "=" << x << endl
#define break break
#define continue continue
#define itn int
#define endl '\n'
#define Endl endl
#define vint vector<ll>
#define pii pair<int, int> 
using namespace std;

int n, k, m;
int a[200005];
itn num[1000005];
void solve(int T)
{
	cin >> n;
	for (int x = 1; x <= 100; x++)
		for (int y = 1; y <= 100; y++)
			for (int z = 1; z <= 100; z++)
				num[(x + z) * (x + z) + (x + y) * (x + y) + (y + z) * (y + z)]++;
	for (int i = 1; i <= n; i++)
		cout << num[i * 2] << endl;
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int numoftest = 1;

	//cin >> numoftest;


	for (int siven = 1; siven <= numoftest; ++siven)
		solve(siven);
	return 0;
}

/*


*/

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

using namespace std;

const long long MOD = 1e9 + 7;
long long dp[101010][5];
string s;

int main() {
  cin >> s;
  int n = s.size();

  for (int i = n; 0 <= i; i--) {
    for (int j = 3; 0 <= j; j--) {
      if (i == n) {
        dp[i][j] = (j == 3 ? 1 : 0);
      } else {
        dp[i][j] = dp[i + 1][j] * (s[i] == '?' ? 3 : 1);
        if (j < 3 && s[i] == '?' || s[i] == "ABC"[j]) {
          dp[i][j] += dp[i + 1][j + 1];
        }
        dp[i][j] %= MOD;
      }
    }
  }
  cout << dp[0][0] << endl;

  return 0;
}

Measured memory_bytes: 4352
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;

int main() {
  
   string n;

   cin >> n;
  
   if(n=="A"){
     
     cout << "T" << endl;
     
   }else if(n=="T"){
     cout << "A" << endl;
   }else if(n=="C"){
     cout << "G" << endl;
   }else if(n=="G"){
     cout << "C" << endl;
   }
  
  
   
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>

#define MAX_N 200'000

using namespace std;

int A[MAX_N];
int D[MAX_N];

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

  int max_d = 0;
  int max_idx = 0;
  for (int i = 0; i < N - 1; ++i) {
    D[i] = min(abs(A[i + 1] - A[i]), abs(A[i] + (K - A[i + 1])));
    if (max_d < D[i]) {
      max_d = D[i];
      max_idx = i;
    }
  }
  D[N - 1] = min(abs(A[N - 1] - A[0]), abs(A[0] + (K - A[N - 1])));
  if (max_d < D[N - 1]) {
    max_idx = N - 1;
  }

  int res = 0;
  for (int i = 0; i < N; ++i) {
    if (i != max_idx) {
      res += D[i];
    }
  }
  printf("%d\n", res);
}

Measured memory_bytes: 4768
N=int(raw_input())

num = [[0 for i in range(10)] for j in range(10)]

for i in range(1,N+1):
    if i % 10 > 0:
        num[int(str(i)[0])][i % 10] += 1

#print num

c = 0
for i in range(1,10):
    for j in range(1,10):
        c += num[i][j]*num[j][i]
print c


Measured memory_bytes: 8964
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    answer071cAlt(n, a)
}

fun answer071cAlt(n: Int, a: List<Long>) {
    val reversedA: MutableList<Long> = a.sortedDescending() as MutableList<Long>

    val set: MutableList<Long> = mutableListOf<Long>()
    var count = 0
    var firstFlg = false
    for (index: Int in reversedA.indices) {
        if (index == 0) {
            continue
        }
        if (reversedA[index] == reversedA[index - 1] && !firstFlg) {
                count += 1
                set.add(reversedA[index])
                firstFlg = true


            if (count == 2) {
                break
            }
        }else {
            firstFlg = false
        }
    }
    if (set.isEmpty()) {
        println(0)
    } else  {
        println(set[0] * set[1])
    }
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int N, a[112345];
	cin >> N;
	REP(i, N) {
		scanf("%d", a + i);
		a[i]--;
	}
	
	int now = 0, ans = 0;
	bool done[112345];
	while (now != 1 && !done[now]) {
		done[now] = true;
		now = a[now];
		ans++;
	}
	
	if (now == 1) cout << ans << endl;
	else puts("-1");
	
	return 0;
}


Measured memory_bytes: 768
h, w = 1, 1
dataset = []
while not(h == w == 0):
    h, w = map(int, input().split())
    dataset.append([h, w])
for n, data in enumerate(dataset):
    h, w = data[0], data[1]
    for i in range(h):
        for j in range(w):
            if  ((i + j) % 2) == 1:
                print(".", end="")
            else:
                print("#", end="")
        print("")
    if n!=len(dataset)-1:
        print("")


Measured memory_bytes: 7020