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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;	
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll INF = 1LL << 61;

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

const ll mod = 1000000007;


int main() {
	ll n, m;
	cin >> n >> m;
	if (n % 2 == 1) {
		for (int i = 0; i < m; i++) {
			cout << i + 1 << " " << n - i - 1 << endl;
		}
	}
	else {
		vector<bool> dist(n + 1, false);
		for (int i = 0, j = 0; i < m; i++, j++) {
			auto left = i + 1;
			auto right = n - j -1;
			while (true) {
				auto c1 = right - left;
				auto c2 = (left - right + n) % n;
				if (dist[c1] || dist[c2] || (c1==c2)) {
					right--;
					j++;
				}
				else {
					dist[c1] = true;
					dist[c2] = true;
					break;
				}
			}
			cout << left << " " << right << endl;
		}
	}
	return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  
  int ans = 0;
  rep(i,N-2){
    if(S.at(i) == 'A'){
      if(S.at(i+1) == 'B'){
        if(S.at(i+2) == 'C') ans ++;
      }
    }
  }
   cout << ans;
  }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    while (1) {
        int n; cin >> n;
        if (n == 0) {
            break;
        }
        int score_a = 0, score_b = 0;
        for (int i=0; i<n; ++i) {
            int a,b;
            cin >> a >> b;
            if (a > b) {
                score_a += a + b;
            } else if (a < b) {
                score_b += a + b;
            } else {
                score_a += a;
                score_b += a;
            }
        }
        cout << score_a << ' ' << score_b << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y); }

int main() {
	int T;
	scanf("%d", &T);
	for (int ii = 0; ii < T; ++ ii) {
		long long A; long long B; long long C; long long D;
		scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
		bool ans = false;
		if (B <= A && B <= D) {
			if (B <= C) {
				ans = true;
			} else {
				auto g = gcd(B, D);
				auto x = C / g * g + A % g;
				while (x <= C) x += g;
				while (C < x - g) x -= g;
				ans = B <= x;
			}
		}
		puts(ans ? "Yes" : "No");
	}
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

void test(){
    lli dd[6] = {-12,32,40,22,60,-20};

    REP(x,-100,100){
        lli sum = 0;
        REP(i,0,6) sum += abs(x-dd[i]);
        cout<<"x="<<x<<" sum="<<sum<<endl;
    }
}


int main(){

    priority_queue<lli> mae;
    priority_queue<lli,vector<lli>,greater<lli>> ushiro;

    mae.push(-INF);
    ushiro.push(INF);

    lli Q;
    cin>>Q;
    lli b=0;

    lli maeSum=0,ushiroSum=0;
    REP(_,0,Q){
        lli tmp;
        cin>>tmp;
        if(tmp==1){
            lli aa,bb;
            cin>>aa>>bb;
            b += bb;

            if(mae.top()>aa){
                mae.push(aa);
                maeSum+=aa;
            }
            else {
                ushiro.push(aa);
                ushiroSum+=aa;
            }

            if(mae.size()>=ushiro.size()+2){
                maeSum-=mae.top();
                ushiroSum += mae.top();
                ushiro.push(mae.top());
                mae.pop();
            }
            if(ushiro.size()>=mae.size()+1){
                maeSum += ushiro.top();
                ushiroSum -= ushiro.top();
                mae.push(ushiro.top());
                ushiro.pop();
            }
        }
        else{
            lli ans = 0;
            ans += abs((ushiroSum) - mae.top()*(lli)(ushiro.size()-1));
            ans += abs((maeSum) - mae.top()*(lli)(mae.size()-1));

            cout<<mae.top()<<" "<<ans+b<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


ll par[100010],siz[100010];

void init(int n){
  FOR(i,n){
    par[i+1]=i+1;
    siz[i+1]=1;
  }
}

ll root(int x){
  return par[x] == x ? x : par[x] = root(par[x]);
}

bool same(int x,int y){
  return root(x) == root(y);
}

void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return;
  if(siz[x]<siz[y])swap(x,y);
  siz[x]+=siz[y];
  par[y]=x;
  
}

ll size(int x){
  return siz[root(x)];
}




int main(){
  ll n,m;
  cin >> n >> m;
  ll a[100010],b[100010];
  init(n);
  FOR(i,m){
    cin >> a[i] >> b[i];
  }
  ll sum=n*(n-1)/2;
vector<ll> ans;
  for(int i=m-1;i>=0;i--){
    ans.push_back(sum);
    if(!same(a[i],b[i])){
      sum-=size(a[i])*size(b[i]);
      
    }
    unite(a[i],b[i]);
  }

  reverse(ans.begin(),ans.end());

  FOR(i,ans.size()){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 5364
#include <cstdio>

#define maxn 1000010
typedef long long ll;
char s[maxn];
int d[maxn], m[maxn];
ll dm[maxn];
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
int main()
{
	int n; scanf("%d", &n);
	scanf("%s", s + 1);
	int q; scanf("%d", &q);
	for (; q; --q)
	{
		int k; scanf("%d", &k);
		ll ans = 0;
		for (int i = 1; i <= n; ++i)
		{
			d[i] = d[i - 1];
			m[i] = m[i - 1];
			dm[i] = dm[i - 1];
			if (s[i] == 'D') ++d[i];
			if (s[i] == 'M') ++m[i], dm[i] += d[i];
			if (s[i] == 'C') ans += dm[i] - dm[dmax(0, i - k)] - 1ll * d[dmax(0, i - k)] * (m[i] - m[dmax(0, i - k)]);
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt = 0;
    for(int i=0; i<N; i++){
        if(S.substr(i,2) == "OX" or S.substr(i,2) == "XO"){
            cnt++;
            i++;
        }
    }
    cout << cnt << enld;
    return 0;
}


Measured memory_bytes: 3348
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  priority_queue<ll>que;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    que.push(a);
  }
  ll ans=0;
  for(int i=0;i<m;i++){
    ll num=que.top();
    que.pop();
    que.push(num/2);
  }
  for(int i=0;i<n;i++){
    ans+=que.top();
    que.pop();
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 2005
#define inf 2000000000
int n,k,q,a[MN],rk[MN],r[MN],len[MN],ans;
bool cho[MN];
bool cmp(int x,int y){return a[x]<a[y];}
inline int solve(){
	register int i,bl=0;
	memset(r,0,sizeof r);
	for(i=1;i<=n;i++)if(!cho[i]){
			if(cho[i-1]) len[++bl]=1;
			else ++len[bl];r[i]=bl;
		}
	int cnt=0,mn=inf,mx=-inf;
	for(i=1;i<=n;i++)if(!cho[rk[i]]){
		if(len[r[rk[i]]]>=k) mn=min(mn,a[rk[i]]),mx=max(mx,a[rk[i]]),--len[r[rk[i]]],++cnt;
		if(cnt==q) break;
	}
	return cnt==q?mx-mn:inf;
}
int main(){
	n=read(),k=read(),q=read();
	register int i;
	for(i=1;i<=n;i++) a[rk[i]=i]=read();
	sort(rk+1,rk+n+1,cmp);
	ans=inf;rk[0]=0;
	for(i=0;i<=n;i++){
		cho[rk[i]]=1;
		ans=min(ans,solve());
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  string str;
 
  cin>>str;
  
  printf("%c",str[0]+('A'-'a'));
 
  cin>>str;
 
  printf("%c",str[0]+('A'-'a'));
 
  cin>>str;
 
  printf("%c\n",str[0]+('A'-'a'));
   
  return 0;

}




Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
count = 0
minj = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if a[j] <a[minj]:
            minj = j
    if i != minj:
        count += 1      
    c = a[i]
    a[i] = a[minj]
    a[minj] = c
    

b = [str(i) for i in a]
print(" ".join(b))
print(count)


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define ll long long int              //cout<<fixed<<setprecision(9)<<double value; 
#define INF 1000000000000000007
#define pb emplace_back 
#define md 1000000007
#define all(s) s.begin(),s.end()
typedef vector<int> vi;
int gh[100005];
int d=13;
ll dp[100005][14];
ll getsum(int idx,int n,int sum){
	if(idx>n)return (sum==5);
	if(dp[idx][sum]!=-1)return dp[idx][sum];
	ll res=0;
	if(gh[idx]!=-1){
		res+=getsum(idx+1,n,(sum*10+gh[idx])%d);
	}
	else{
		for(int i=0;i<=9;i++){
			res+=getsum(idx+1,n,(sum*10+i)%d);
		}
	}
	/*for(int i=0;i<=limit;i++){
		if(i<limit||flag){
			res+=getsum(idx+1,n,(sum+i)%d,true);
		}
		else{
			res+=getsum(idx+1,n,(sum+i)%d,false);
		}
	}*/
	return dp[idx][sum]=res%md;
}
void solve(){
	string b;
	cin>>b;
	//cin>>d;
	for(int i=0;i<b.size();i++){
		if(b[i]=='?')
		gh[i+1]=-1;
		else
		gh[i+1]=b[i]-'0';
	}
	memset(dp,-1,sizeof dp);
    ll r=getsum(1,b.size(),0);
   cout<<(r)%md<<"\n";
}
int main(){
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
   int t=1;
  // cin>>t;
     while(t--){
     	solve();
	 }
     return 0;
}


Measured memory_bytes: 22920
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  /// freopen("input.txt","r",stdin);
  /// freopen("output.txt","w",stdout);
	lli t=1;
    //cin>>t;
	while(t--)
	{
        lli n,k,i,j;
        string s;
        cin>>s;
        lli f=(int(s[0])-48)*10+(int(s[1])-48);
        lli sc=10*(int(s[2])-48)+(int(s[3])-48);
        if(f>12&&sc>12)
        {
            cout<<"NA"<<endl;
        }
        else if(f<=12&&f>00&&(sc>12||sc==0))
        {
            cout<<"MMYY"<<endl;
        }
        else if(sc<=12&&sc>0&&(f>12||f==0))
        {
            cout<<"YYMM"<<endl;
        }
        else if(f>0&&f<=12&&sc>0&&sc<=12)
        {
            cout<<"AMBIGUOUS"<<endl;
        }
        else
        {
            cout<<"NA"<<endl;
        }
    }
}
/*
1
8 2
1 0 1 0 0 1 0 0
*/


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		
		
		Map<String,Integer> mapping= initializeAlphabetMapping();
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			
			String line = sc.next().toLowerCase();
			
			for(int i =0;i<line.length();i++){
				
				if(!Character.isAlphabetic(line.charAt(i))){
					continue;
				}
				
				String character = String.valueOf(line.charAt(i));
				
				mapping.put(character, mapping.get(character)+1);
				
			}
			
		}
		
		for(Entry<String,Integer> entry : mapping.entrySet()){
			
			System.out.println(entry.getKey() + " : " + entry.getValue());
			
		}
		
		sc.close();
		
	}

	private static Map<String, Integer> initializeAlphabetMapping() {
		
		HashMap<String,Integer> mapping = new LinkedHashMap<String,Integer>(){
				{
					put("a",0);
					put("b",0);
					put("c",0);
					put("d",0);
					put("e",0);
					put("f",0);
					put("g",0);
					put("h",0);
					put("i",0);
					put("j",0);
					put("k",0);
					put("l",0);
					put("m",0);
					put("n",0);
					put("o",0);
					put("p",0);
					put("q",0);
					put("r",0);
					put("s",0);
					put("t",0);
					put("u",0);
					put("v",0);
					put("w",0);
					put("x",0);
					put("y",0);
					put("z",0);
				
				}
		};
		
		return mapping;
	}
}



Measured memory_bytes: 26320
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Map<Integer, Integer> map = new HashMap<>();
    for(int i = 0; i < n; i++){
      int tmp = sc.nextInt();
      if(!map.containsKey(tmp)){
        map.put(tmp, 0);
      }
      map.put(tmp, map.get(tmp) + 1);
    }
    int sum = 0;
    for(int num : map.keySet()){
      if(num == map.get(num)){
        continue;
      }else if(num < map.get(num)){
        sum += map.get(num) - num;
      }else{
        sum += map.get(num);
      }
    }
    System.out.println(sum);
  }
}

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

int main() {
  string S, T;
  cin >> S;
  cin >> T;
  int ans = 0;
  for(int i=0;i<S.size();i++){
    if(S[i] != T[i]){
      ans ++;
    }
  }
  cout << ans << endl;
 
}


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

if n >= m:
  print('0')
  exit(0)

x_sorted = sorted(x)
dx = [abs(x_sorted[i+1]-x_sorted[i]) for i in range(m-1)]
dx_sorted = sorted(dx,reverse=True)

result = sum(dx_sorted)
for i in range(n-1):
  result -= dx_sorted[i]
print(result)

Measured memory_bytes: 20428
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    for(int i = 1; i <= 9; i++){
        for(int j =1; j <= 9; j++){
            if(i * j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    
}


Measured memory_bytes: 384
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> list = nextIntArray();
      int output = 0;
      for(int i = 0; i < N; i++){
        output += list.get(i) - 1;
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33472
n = int(input())
a = list(map(int, input().split()))

d = {}
for x in a:
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

h = []
for x, y in d.items():
    if y >= 4:
        h.append(x)
        h.append(x)
    elif y >= 2:
        h.append(x)

if len(h) < 2:
    print(0)
else:
    h = list(sorted(h))
    print(h[len(h)-1] * h[len(h)-2])

Measured memory_bytes: 18060
#include<stdio.h>
#include<stdlib.h>

struct Node{
  int key;
  struct Node *r,*l,*p;
};

 struct Node *B,*NIL;

void insert(int k){
   struct Node *y = NIL;
   struct Node *x = B;
   struct Node *z;

   z = (struct Node *)malloc(sizeof(struct Node));
   z->key = k;
   z->l = NIL;
   z->r = NIL;

   while(x!=NIL){
     y = x;
     
     if(z->key < x->key){
       x = x->l;
     }
     else x = x->r;
   }
   
   z->p = y;
   if(y == NIL ){
     B=z;
   }
   else if(z->key < y->key){
       y->l = z;
     }
   else y->r = z;
}

struct Node* find(int k,struct Node *u){
  while( u != NIL && k != u->key ){
    if(k < u->key) u = u->l;
    else u = u->r;
  }
  return u;
}


void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u == NIL )return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  
  int i,j,x,y;
  char G[8];
  struct Node *s;
  scanf("%d",&x);
  
  for(i=0;i<x;i++){
    scanf("%s",&G);
    
    if(G[0] == 'i'){
      scanf("%d",&y);
      insert(y);
    }
    
    else if(G[0] == 'p'){
      inorder(B);
      printf("\n");
      preorder(B);
      printf("\n");
    }

    else if(G[0]=='f'){
      scanf("%d",&y);
      s = find(y,B);
      if(s != NIL) printf("yes\n");
      else if(s == NIL)printf("no\n");
    }
  }
  return 0;
}

  



Measured memory_bytes: 20456
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
// #include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double M_PI = 3.141592653589793238;
int x1, x2, y1, y2;
int N;
int X[200000], Y[200000];
int lis[200000];
vector<P> p;
const int INF = 1e+9;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> x1 >> y1 >> x2 >> y2;
    if(x1 > x2){
        swap(x1, x2);
        swap(y1, y2);
    }
    cin >> N;
    int yl = min(y1, y2);
    int yr = max(y1, y2);
    for(int i = 0; i < N; i++) {
        int X_, Y_;
        cin >> X_ >> Y_;
        if(Y_ >= yl && Y_ <= yr && X_ >= x1 && X_ <= x2){
            if(y1 > y2) Y_ *= -1;
            p.push_back(P(X_, Y_));
        }
    }
    if(y1 > y2) {
        y1 *= -1;
        y2 *= -1;
    }
    sort(p.begin(), p.end());
    for(int i = 0; i < N; i++) lis[i] = INF;
    int M = p.size();
    for(int i = 0; i < M; i++){
        int x = p[i].first;
        int y = p[i].second;
        int* ptr = lower_bound(lis, lis+M, y);
        *ptr = y;
    }
    int cnt = 0;
    
    for(int i = 0; i < M; i++){
        if(lis[i] != INF) cnt = i+1; 
    }
    double ans = (double)100*(y2-y1)+(double)100*(x2-x1);
    if(x1 == x2){
        if(cnt == 1){
            ans += (M_PI*10-20);
        }
        cout << ans << endl;
        return 0;
    }
    if(y1 == y2){
        if(cnt == 1){
            ans += (M_PI*10-20);            
        }
        cout << ans << endl;
        return 0;
    }
    
    if(min(y2-y1, x2-x1)+1 == cnt) {
        ans += (M_PI*10-20);
        cnt--;
    }
    ans -= (20.0-M_PI*5)*cnt;
    cout << ans << endl;
}

Measured memory_bytes: 2800
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long diff = b-a;
        long ans = 0L;
        if(diff % 2L == 0){
            ans = diff / 2L;
        }else{
            long h = (n+1L)/2L;
            if(b <= h){
                ans = b-1L;
            }else if(h < a){
                ans = n-a;
            }else if(n-a < b-1L){
                ans = n-a;
            }else{
                ans = b-1L;
            }
            if(1 < b-a) ans -= (b-a-1L)/2L;
        }
        System.out.println(ans);
        sc.close();

    }

}


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

int main() {
	int n, a, mn = 1001, mx = -1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (mn > a) mn = a;
		if (mx < a) mx = a;
	}
	cout << mx - mn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int a1=0,a0=0;
    string s;
    cin>>s;
    int len=s.size();
    for (int i=0;i<len;i++)
    {
        if(s[i]=='1')
            a1++;
        else
            a0++;
    }
    if(a1>a0)
        cout<<a0*2<<endl;
    else
        cout<<a1*2<<endl;
    return 0;
}

Measured memory_bytes: 512
import itertools

N = int(input())

# input整理
X = []
Y = []
for i in range(0,N):
    x, y = input().split()
    X.append(int(x))
    Y.append(int(y))

seq = range(0,N)
kumi = list(itertools.permutations(seq))

sum = 0
for k in kumi:
    for i, k_i in enumerate(k[:N-1]):
        n_i = k[i + 1]
        sum += ((X[k_i] - X[n_i]) ** 2 + (Y[k_i] - Y[n_i]) ** 2) ** 0.5

print(sum / len(kumi))


# print((2**0.5*4 + 8)/6)


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

using namespace std;

int main(){
  int K,A,B,i;
  cin >> K >> A >> B;
  
  for(i=A;i<=B;i++){
    if(i%K==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  
  cout << "NG" << endl;
}

Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace D_ABC172
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int n = s[0];
            long[] l = new long[n + 1];

            for (int i = 1; i < n + 1; i++)
            {
                for (int j = 1; j <= (n ) / i; j++)
                {
                    l[j * i]++;
                    // WriteLine("i : {0} j : {1}",i,j);
                }
            }

            long ans = 0;
            for (int i = 1; i < n + 1; i++)
            {
                ans += i*l[i];
                // WriteLine(l[i]);

            }
            WriteLine(ans);





        }
    }
}


Measured memory_bytes: 105784
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
int A[MAXN];

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        A[i] /= 2;
    }
    LL mlcm = A[0];
    for (int i = 1; i < N; i++) {
        mlcm = mlcm * A[i] / __gcd(mlcm, (LL)A[i]);
        if (mlcm > M) return !printf("0\n");
    }
    //printf("mlcm = %lld\n", mlcm);
    for (int i = 0; i < N; i++) {
        LL tmp = mlcm / A[i];
        if ((tmp % 2) == 0)
            return !printf("0\n");
    }
    LL ans = M / mlcm;
    printf("%lld\n", ans / 2 + (ans % 2));
    return 0;
}


Measured memory_bytes: 768
def main():
    n, k = map(int, input().split())
    hit_list = list(map(int, input().split()))

    hit_list.sort(reverse=True)

    if n <= k:
        print(0)
        exit()

    for i in range(k):
        hit_list[i] = 0

    print(sum(hit_list))

if __name__ == '__main__':
    main()

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if((A+B)==(C+D)) cout << "Balanced" << endl;
  else if((A+B)>(C+D)) cout << "Left" << endl;
  else cout << "Right" << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define N 100

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n, M[N][N], d[N];


void bfs(int s) {
  queue<int> Q;
  Q.push(s);
  REP0(i,n) d[i]=INTINF;
  d[s]=0;
  int u;
  while ( !Q.empty() ) {
    u = Q.front(); Q.pop();
    REP0(v,n){
      if (M[u][v]==0 || d[v]!=INTINF) continue; //disconnected or visited
      d[v] = d[u]+1;
      Q.push(v);
    }
  }
  REP0(i,n){
    std::cout << i+1 << " " << ( (d[i]==INTINF) ? (-1) : d[i] ) << '\n';
  }
}


void input(){
  std::cin >> n;
  int v1, v2, d;
  REP0(i,n) { REP0(j,n) M[i][j]=0; }
  REP0(i,n){
    std::cin >> v1 >> d;
    REP0(j,d){
      std::cin >> v2; M[v1-1][v2-1]=1;
    }
  }
}


int main(int argc, char const *argv[]) {
  cin.tie(0); ios::sync_with_stdio(false);
  input();
  bfs(0);
  return 0;
}



Measured memory_bytes: 3176
package main

import (
	"fmt"
	"sort"
)

type Restaurant struct {
	Index int
	Name  string
	Point int
}

type Restaurants []Restaurant

func (r Restaurants) Len() int {
	return len(r)
}

func (r Restaurants) Less(i, j int) bool {
	return r[i].Name < r[j].Name || r[i].Name == r[j].Name && r[i].Point > r[j].Point
}

func (r Restaurants) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func main() {
	var n int
	fmt.Scan(&n)
	var slice []Restaurant
	for i := 0; i < n; i++ {
		var s string
		var p int
		fmt.Scan(&s, &p)
		r := Restaurant{i + 1, s, p}
		slice = append(slice, r)
	}

	sort.Sort(Restaurants(slice))

	for _, e := range slice {
		fmt.Println(e.Index)
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  cout<<(s<t?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n,m;
int fa[maxn];
int find(int x){return (fa[x]==x ? x : fa[x]=find(fa[x]));}
int a[maxn];
vector<int>val[maxn];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		fa[i]=i;
	}
	while(m--){
		int u,v;
		scanf("%d%d",&u,&v);
		u++;v++;
		fa[find(u)]=find(v);
	}
	for(int i=1;i<=n;i++){
		val[find(i)].push_back(a[i]);
	}
	int cnt=0;
	int pt=0,one=0;
	for(int i=1;i<=n;i++){
		sort(val[i].begin(),val[i].end());
		cnt+=(val[i].size()>0);
		if(val[i].size()>1)
			pt+=val[i].size()-1;
		if(val[i].size()==1)
			one++;
	}
	if(cnt==1){
		puts("0");
		return 0;
	}
	if(one>pt){
		puts("Impossible");
		return 0;
	}

	int sel=2*(cnt-1)-cnt;
	vector<int>num;
	long long ans=0;

	for(int i=1;i<=n;i++)if(val[i].size()){
		ans+=val[i][0];
		for(int j=1;j<val[i].size();j++){
			num.push_back(val[i][j]);
		}
	}
	sort(num.begin(),num.end());
	if(num.size()<sel){
		puts("Impossible");
		return 0;
	}
	for(int i=0;i<sel;i++){
		ans+=num[i];
	}

	cout<<ans<<endl;



	return 0;
}

Measured memory_bytes: 6528
# E
H, W = map(int, input().split())
grid = []
for i in range(H):
    grid.append(list(input()))

res = 0
# cross
cross_posi = [[0]*(H+W-1) for _ in range(H+W-1)]
for i in range(H):
    for j in range(W):
        if grid[i][j] == "#":
            cross_posi[i+j][i-j+W-1] = 1
            
# pre-compute
cross_posi_1 = [[0]*(H+W) for _ in range(H+W-1)]
for i in range(H+W-1):
    r = 0
    for j in range(H+W-1):
        r += cross_posi[i][j]
        cross_posi_1[i][j+1] = r
        
cross_posi_2 = [[0]*(H+W) for _ in range(H+W-1)]
for i in range(H+W-1):
    r = 0
    for j in range(H+W-1):
        r += cross_posi[j][i]
        cross_posi_2[i][j+1] = r

for s in range(H+W-1):
    for t in range((s+W+1)%2, H+W-2, 2):
        if cross_posi[s][t] == 1:
            for u in range(t+2, H+W-1, 2):
                if cross_posi[s][u] == 1:
                    d = (u - t)
                    if s >= d:
                        res += cross_posi_1[s-d][u+1] - cross_posi_1[s-d][t]
                    if s+d < H+W-1:
                        res += cross_posi_1[s+d][u+1] - cross_posi_1[s+d][t]
for s in range(H+W-1):
    for t in range((s+W+1)%2, H+W-2, 2):
        if cross_posi[t][s] == 1:
            for u in range(t+2, H+W-1, 2):
                if cross_posi[u][s] == 1:
                    d = (u - t)
                    if s >= d:
                        res += cross_posi_2[s-d][u] - cross_posi_2[s-d][t+1]
                    if s+d < H+W-1:
                        res += cross_posi_2[s+d][u] - cross_posi_2[s+d][t+1]
print(res)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N; cin >> N;
	string s1,s2; cin >> s1 >> s2;

	ll ans = 1;
	ll mod = 1e9+7;

	for (int i = 0;i < N;i++){
		if(s1[i] == s2[i]){
			if(i == 0){
				ans *= 3;
			}else if(s1[i-1] == s2[i-1]){
				ans *= 2;
			}
		}else{
			if(i == 0){
				ans *= 6;
			}else if(s1[i-1] != s2[i-1]){
				ans *= 3;
			}else{
				ans *= 2;
			}
			i++;
		}
		ans %= mod;
	}

	cout << ans << endl;

	return 0;

}


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

int main()
{
    int N, K;
    cin >> N >> K;

    int R, S, P;
    cin >> R >> S >> P;

    string T;
    cin >> T;    

    long long score = 0;
    for (int i = 0; i < N; i++) {
        if ((i + 1) > K) {
            if (T[i - K] == T[i]) {
                T[i] = 'x';
                continue;
            }
        }
        switch (T[i]) {
        case 'r':
            score += P;
            break;
        case 's':
            score += R;
            break;
        case 'p':
            score += S;
            break;
        }
    }

    cout << score << endl;

    return 0;
}

Measured memory_bytes: 512
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef std::pair<int,int> P;
#define mk std::make_pair
#define fr first
#define sc second
inline int in()
{
	int k=0;char ch=gt;bool p=1;
	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return p?k:-k;
}
const int N=3005,YL=1e9+7;
inline int MO(const int &x){return x>=YL?x-YL:x;}
inline void add(int &x,int y){if((x+=y)>=YL)x-=YL;}
int f[2][N][2],now;
int main()
{
	int n=in(),m=in();f[now][0][1]=1;
	for(int i=1;i<=n;++i)f[now][i][0]=1;
	for(int i=1;i<=m;++i)
	{
		now^=1;memset(f[now],0,sizeof f[now]);
		for(int j=1;j<=n;++j)add(f[now][j][0],f[now^1][j-1][0]);//WW
		for(int j=1;j<=n;++j)add(f[now][j][1],f[now^1][j-1][1]);
		for(int j=1;j< n;++j)add(f[now][j][0],f[now^1][j+1][0]);//BB
		for(int j=1;j< n;++j)add(f[now][j][1],f[now^1][j+1][1]);
		add(f[now][0][1],f[now^1][1][1]),add(f[now][0][1],f[now^1][1][0]);
		for(int j=0;j< n;++j)add(f[now][j][0],f[now^1][j][0]);//WB
		for(int j=0;j< n;++j)add(f[now][j][1],f[now^1][j][1]);
		for(int j=2;j<=n;++j)add(f[now][j][0],f[now^1][j][0]);//BW
		for(int j=2;j<=n;++j)add(f[now][j][1],f[now^1][j][1]);
		add(f[now][1][1],f[now^1][1][1]),add(f[now][1][1],f[now^1][1][0]);
	}
	int ans=0;
	for(int i=0;i<=n;++i)add(ans,f[now][i][1]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int MAXN =(int) 3e3+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int R;
void work(){
    scanf("%d",&R);
    printf("%.12lf\n",R*2*pi);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}





Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll N, M;
    cin >> N >> M;
    VL A(M);
    rep(i, 0, M) cin >> A[i];
    ll total = 0;
    rep(i, 0, M) total += A[i];

    if(total > N) cout << -1 << endl;
    else cout << (N - total) << endl;

    return 0;
}


Measured memory_bytes: 3652
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.PriorityQueue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val K = in.next().toInt


  // Dijkstra
  val edge = Array.fill[List[(Int, Int)]](K)(Nil)  // (node, cost)
  for(i <- 0 until K) {
    edge(i) = ((i+1) % K, 1) :: edge(i)
    edge(i) = ((i*10) % K, 0) :: edge(i)
  }

  // fro から to への最短距離(v は頂点数)
  def dijkstra(from: Int, to: Int, v: Int): Int = {
    val MAX = Int.MaxValue

    val dist = Array.fill(v)(MAX)   // fro からの距離を格納する
    val check = new Array[Boolean](v)  // すでにその頂点からを調べたかのフラグ

    dist(from) = 0

    val pq = new PriorityQueue[(Int, Int)]  // (-cost, node) queue
    pq.enqueue((-0, from))

    // 頂点は v 個あるので、v 周する
    for(_ <- 0 until v) {
      // 調べ済みでない頂点のうち、最も近い頂点を now に入れる
      var nowNode = -1       // このターンにフォーカスするノード

      breakable {
        while(true) {
          nowNode = pq.dequeue._2  // 最小コストから貪欲に取っていく
          if(!check(nowNode)){  // まだチェックされていないノードだったら決定
            check(nowNode) = true
            break
          }
        }
      }

      // その頂点からたどり着ける頂点の情報を更新する
      for((nextNode, cost) <- edge(nowNode)) {
        val nextDist = dist(nowNode) + cost
        if(nextDist < dist(nextNode)){  // 既存の通路より近いなら更新
          dist(nextNode) = nextDist
          pq.enqueue((-nextDist, nextNode))
        }
      }
    }

    dist(to)
  }


  println(dijkstra(1, 0, K) + 1)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 88456
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<int,int> P;
typedef pair<int,P> P2;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n;
  while(cin >> n && n) {
    P d[n];
    d[0]=P(0,0);
    P2 a[n-1];
    for(int i=0; i<n-1; i++) {
      cin >> a[i].F >> a[i].S.S;
      a[i].S.F=i+1;
    }
    sort(a,a+n-1);
    int x1=0,x2=0,y1=0,y2=0;
    for(int i=0; i<n-1; i++) {
      d[a[i].S.F].F=d[a[i].F].F+dx[a[i].S.S];
      d[a[i].S.F].S=d[a[i].F].S+dy[a[i].S.S];
      x1=max(x1,d[a[i].S.F].F);
      x2=min(x2,d[a[i].S.F].F);
      y1=max(y1,d[a[i].S.F].S);
      y2=min(y2,d[a[i].S.F].S);
    }
    cout << x1-x2+1 << " " << y1-y2+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1164
using System;
class A{
static void Main()

{while(true){
int a=int.Parse(Console.ReadLine());
if(a==0){break;}
string [,]s=new string[a,2];
for(int i=0;i<a;i++)
{
string yu=Console.ReadLine();
s[i,0]=yu.Substring(0,1);
s[i,1]=yu.Substring(2,1);
}int g=int.Parse(Console.ReadLine());
for(int k=0;k<g;k++)
{bool flag=false;
string d=Console.ReadLine();
for(int i=0;i<a;i++)
{
if(d==s[i,0]){flag=true;Console.Write(s[i,1]);break;}
}
if(!flag){Console.Write(d);}
}Console.WriteLine();
}
/////////
}
}

Measured memory_bytes: 8796
N = int(input())
A = list(map(int, input().split()))

d = [0] * 9
for a in A:
    if a < 400:
        d[0] = 1
    elif a < 800:
        d[1] = 1
    elif a < 1200:
        d[2] = 1
    elif a < 1600:
        d[3] = 1
    elif a < 2000:
        d[4] = 1
    elif a < 2400:
        d[5] = 1
    elif a < 2800:
        d[6] = 1
    elif a < 3200:
        d[7] = 1
    else:
        d[8] += 1

base = sum(d[:-1])
mx = base + d[8]
mn = max(1, base)
print(mn, mx)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int i,j;
    int cnt=0;
    for(i=1; i<=n; ++i){
        int p=0;
        if(i%2==1){
        for(j=1; j<=i; ++j){
            if(i%j==0){
                ++p;
            }
        }
        if(p==8){
            ++cnt;
        }
        }
    }
    printf("%d\n", cnt);
}

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

bool comp(const pair<int, int>& x, const pair<int, int>& y) {
    if (x.first == y.first) return x.second < y.second;
    else return x.first < y.first;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> requests(m);
    for (int i = 0; i < m; ++i) {
        cin >> requests[i].first >> requests[i].second;
    }
    sort(requests.begin(), requests.end(), comp);
    int ans = 1;
    int l = requests[0].first;
    int r = requests[0].second;
    for (int i = 1; i < m; ++i) {
        if (requests[i].first >= r) {
            ++ans;
            r = requests[i].second;
        } else {
            if (requests[i].second < r) {
                r = requests[i].second;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n;
struct Tree{
	set<int> e[110];
	int fa[110];
	void init(){
		for(int i=1;i<n;i++){
			int x,y;read(x);read(y);
			e[x].insert(y);
			e[y].insert(x);
		}
	}
	void dfs(int x,int dad){
		fa[x]=dad;
		for(int v:e[x]) if(v!=dad) dfs(v,x);
	}
	int solve(int *p,int rt){
		dfs(rt,0);
		int s=0,tag[110]={};
		for(int i=1;i<=n;i++)
			if(i!=rt) tag[i]=fa[i]!=p[i],s+=tag[i];
		for(int i=1;i<=n;i++)
			if(i!=rt&&tag[fa[i]]&&!tag[i]) return 1e9;
		int d[110]={};
		vector<int> pre[110];
		for(int i=1;i<=n;i++){
			if(i!=rt&&tag[i]&&tag[fa[i]]){
				pre[fa[i]].push_back(i);
				d[i]++;
			}
			if(i!=rt&&tag[i]&&tag[p[i]]){
				pre[i].push_back(p[i]);
				d[p[i]]++;
			}
		}
		queue<int> q;int now=0;
		for(int i=1;i<=n;i++)
			if(i!=rt&&tag[i]&&!d[i]) q.push(i);
		while(!q.empty()){
			int u=q.front();q.pop();now++;
			for(int v:pre[u])
				if(--d[v]==0) q.push(v);
		}
		if(now==s) return s;
		else return 1e9;
	}
};
int main(){
	int T;read(T);
	while(T--){
		Tree T1,T2;
		read(n);
		T1.init();
		T2.init();
		int flag=1,ans=1e9;
		for(int i=1;i<=n;i++)
			if(T1.e[i]!=T2.e[i]) flag=0;
		if(flag){puts("0");continue;}
		for(int i=1;i<=n;i++){
			T2.dfs(i,0);
			if(T1.e[i].size()!=1) continue;
			for(int j=1;j<=n;j++)
				if(j!=i){
					Tree t=T1;
					t.e[*t.e[i].begin()].erase(i);
					t.e[i].clear();
					t.e[i].insert(j);
					t.e[j].insert(i);
					ans=min(ans,t.solve(T2.fa,i)+1);
				}
		}
		if(ans>1e8) ans=-1;
		cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[10005], a[1005], b[1005];
int min(int a, int b){
    if(a == -1 || a > b) return b;
    return a;
}
int main(){
    memset(dp, -1, sizeof(dp));
    int h, n;
    scanf("%d%d", &h, &n);
    for(int i=1;i<=n;i++) scanf("%d%d", &a[i], &b[i]);
    dp[h] = 0;
    int ans = 1e9;
    for(int i=h;i>=0;i--){
        if(dp[i] == -1) continue;
        for(int j=1;j<=n;j++){
            if(i-a[j] <= 0) ans = min(ans, dp[i]+b[j]);
            else dp[i-a[j]] = min(dp[i-a[j]], dp[i]+b[j]);
        }
    }
    printf("%d\n", ans);
}

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

using namespace std;

string find1(const string &s, const string &p)
{
	string t;
	string::size_type offset = 0;
	for (string::size_type pos; (pos = s.find(p, offset)) != string::npos; ++offset) {
		if (pos + p.length() + 1 <= s.length()) {
			string x = s.substr(pos, p.length() + 1);
			if (t.empty() || x < t) {
				t = x;
			}
		}
	}
	return t;
}

string find2(const string &s, const string &p)
{
	char mn = 'z';
	for (auto c : s) {
		if (c != p[0]) {
			mn = min(mn, c);
		}
	}
	return string(1, mn);
}

int main()
{
	string s;
	int K;

	cin >> s;
	cin >> K;

	vector<string> v(K);

	v[0] += *min_element(s.begin(), s.end());
	for (int i = 1; i < K; ++i) {
		auto t = find1(s, v[i - 1]);
		if (t.empty()) {
			v[i] = find2(s, v[i - 1]);
		} else {
			v[i] = t;
		}
	}
	cout << v.back()<< endl;
}


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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    int n, m; 
    cin >> n >> m; 
    vector<bool> ja_ac(n+1); 
    vector<int> wrong(n+1); 
    for (int i = 1; i <= m; i++) {
        int prob; cin >> prob;
        string res; cin >> res; 
        if (!ja_ac[prob]) {
            if (res == "WA") wrong[prob]++; 
            if (res == "AC") ja_ac[prob]=true; 
        }
    }

    int pen = 0; 
    int acs = 0; 
    for (int i = 0; i <= n+1; i++) 
    {
        if (ja_ac[i]) {
            pen += wrong[i]; 
            acs++; 
        }
    }


    cout << acs << " " << pen << "\n"; 





    return 0; 
}



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

using namespace std;

#define all(v) v.begin(), v.end()
#define F first
#define S second
#define FOR(i, n) for(int i = 0; i < (int) n; i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

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

	int n, m; cin >> n >> m;
	if(m == n) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
P=[int(i)+1 for i in input().split()]
left = 0
right = K
max_=sum(P[:K])
ans=max_
#print(max_)
for _ in range(N-K):
    ans=max(ans,max_ - P[left] + P[right])
    max_=max_ - P[left] + P[right]
    left += 1
    right += 1
print(ans/2)

Measured memory_bytes: 71792
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i < (b); ++i)
#define F2(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i > (b); --i)
#define dF2(i, a, b) for (int i = (a); i >= (b); --i)
#define maxn 310
using namespace std;
typedef long long LL;
char ss[maxn];
int dp[maxn][maxn][maxn];
int main() {
    int k;
    scanf("%s%d", ss, &k);
    int n = strlen(ss), ans=0;
    dF2(l, n-1, 0) {
        F(r, l, n) {
            F2(x, 0, k) {
                if (ss[l]==ss[r]) dp[l][r][x] = dp[l+1][r-1][x]+(l==r?1:2);
                else {
                    dp[l][r][x] = max(dp[l+1][r][x], dp[l][r-1][x]);
                    if (x) dp[l][r][x] = max(dp[l][r][x], dp[l+1][r-1][x-1]+2);
                }
            }
        }
    }
    printf("%d\n", dp[0][n-1][k]);
    return 0;
}


Measured memory_bytes: 112768
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string s,t;
  cin>>s>>t;
  int n=0;
  rep(i,0,s.size()){
    if(s[i]==t[i]) n++;
  }
  if(n==s.size()) co("Yes");
  else co("No");
  
  return 0;
}

Measured memory_bytes: 3628