akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int ab[2];
    cin>>ab[0]>>ab[1];
    
    sort(ab,ab+2);
    int ans=ab[1];
    ab[1]--;
    sort(ab,ab+2);
    ans+=ab[1];
    cout1(ans)
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] S = new int[M];
        int[] C = new int[M];
        int[] result = new int[N];
        for(int i = 0; i < N; i++) result[i] = 100;
        for(int i = 0; i < M; i++) {
            S[i] = Integer.parseInt(sc.next());
            C[i] = Integer.parseInt(sc.next());
            
            if(S[i] == 1 && C[i] == 0 && N != 1) {
                System.out.println(-1);
                return ;
            }
        }

        for(int i = 0; i < M; i++) {
            if(result[S[i] -1] != 100 && result[S[i] - 1] != C[i]) {
                System.out.println(-1);
                return;
            }
            result[S[i] - 1] = C[i];
        }
        String numStr = "";
        if(result[0] == 100 && N == 1) result[0] = 0;
        if(result[0] == 100) result[0] = 1;
        numStr += Integer.toString(result[0]);
        for(int i = 1; i < N; i++) {
            if(result[i] == 100) result[i] = 0;
            numStr += Integer.toString(result[i]);
        }

        System.out.println(numStr);
    }
}

Measured memory_bytes: 22996
#include<stdio.h>
#include<string.h>
int main (){
	char str[100];
	scanf("%s",str);
	int i,test,test2;
	test=0;
	test2=0;
	//even
	for (i=1;str[i]!='\0';i+=2){
		if (str[i]=='R')
		test=1;
	}
	//odd
	for (i=0;str[i]!='\0';i+=2){
		if (str[i]=='L')
		test2=1;
	}
	if (test==0 && test2==0){
		printf("Yes\n");
	}
	else
	printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

int main()
{
	int H,W,x,y;
	cin >> H >> W >> x >> y;
	cout << H*W - H*y - (W - y)*x << endl;

}




Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int n, x;
	cin >> n >> x;
	set<int> s;
	int bot = 2*n-1;
	int ans[bot] = {};
	REP1(i, bot) s.insert(i);
	if(x == bot || x == 1) cout << "No" << endl;
	else if(n != 2){
		if(x == bot-1){
			ans[bot/2] = x;
			ans[bot/2 + 1] = x + 1;
			ans[bot/2 - 1] = x - 1;
			ans[bot/2 + 2] = x - 2;
			s.erase(x);
			s.erase(x+1);
			s.erase(x-1);
			s.erase(x-2);
		}
		else{
			ans[bot/2] = x;
			ans[bot/2 + 1] = x - 1;
			ans[bot/2 - 1] = x + 1;
			ans[bot/2 + 2] = x + 2;
			s.erase(x);
			s.erase(x-1);
			s.erase(x+1);
			s.erase(x+2);
		}
		REP(i, bot){
			if(ans[i]==0){
				//cout << s.size();
				ans[i] = *s.begin();
				s.erase(*s.begin());
			}
		}
		cout << "Yes" << endl;
		REP(i,bot) cout << ans[i] << endl;
	}
	else{
		cout << "Yes" << endl;
		REP1(i,bot) cout << i << endl;
	}
}

Measured memory_bytes: 13720
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
const int INF = (1<<21);

class state{
public:
  int d,n;
  state(int d=0,int n=0):d(d),n(n){}
};

int main(){
  int n;
  while(cin >> n){
    bool d[100][100];
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) d[i][j] = false;
    for(int i=0;i<n;i++){
      int a,b;
      cin >> a >> b;
      a--;
      for(int j=0;j<b;j++){
	int c;
	cin >> c;
	c--;
	d[a][c] = true;
      }
    }

    int m;
    cin >> m;
    while(m--){
      int a,b,c;
      queue<state> Q;
      bool f[100];
      for(int i=0;i<n;i++) f[i] = false;
      cin >> a >> b >> c;
      a--;
      b--;

      state u(a,1);
      int ans = INF;
      Q.push(u);

      while(!Q.empty()){
	u = Q.front();
	Q.pop();
	f[u.d] = true;

	if(u.d == b){
	  if(u.n <= c) ans = u.n;
	  break;
	}

	for(int i=0;i<n;i++){
	  if(!f[i] && d[u.d][i]){
	    state v = u;
	    v.d = i;
	    v.n++;
	    Q.push(v);
	  }
	}
      }

      if(ans == INF) cout << "NA" << endl;
      else cout << ans << endl;

    }
  }
  return 0;
}

Measured memory_bytes: 920
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n=in();
  vector<string> s(n);
  rep(i,n){ cin >> s[i]; sort(all(s[i])); }
  unordered_map<string, int> m;
  rep(i,n){
    m[s[i]]++;
  }
  ll ret = 0;
  for(auto kv : m){
    ll n = kv.second;
    ret += (n * (n-1)) / 2;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 16036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int Q; cin >> Q;
	V<ll> p3(31);
	p3[0] = 1; rep(i,30) p3[i+1] = p3[i]*3;
	auto Inc = [&](ll x, ll y){
		if(x>y) swap(x,y);
		rep1(i,3){
			ll d = x+i;
			if(x<d&&d<y&&d%3==1) return true;
		}
		return false;
	};
	auto solve = [&](ll a,ll b,ll c,ll d){
		per(k,30){
			ll L = p3[k];
			ll aa = a/L, bb = b/L, cc = c/L, dd = d/L;
			if(aa == cc && aa%3 == 1 && Inc(bb,dd)){
				shows(aa,bb,cc,dd);
				ll X = a/L*L-1;
				ll Y = X+L+1;
				return abs(b-d) + min(abs(a-X)+abs(c-X),abs(a-Y)+abs(c-Y));
			}
			if(bb == dd && bb%3 == 1 && Inc(aa,cc)){
				shows(L,aa,bb,cc,dd);
				swap(a,b);swap(c,d);
				ll X = a/L*L-1;
				ll Y = X+L+1;
				return abs(b-d) + min(abs(a-X)+abs(c-X),abs(a-Y)+abs(c-Y));
			}
			if(aa != cc && bb != dd){
				return abs(a-c)+abs(b-d);
			}
		}
		return abs(a-c)+abs(b-d);
	};
	while(Q--){
		ll a,b,c,d; cin >> a >> b >> c >> d;
		a--,b--,c--,d--;
		cout << solve(a,b,c,d) << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int A, B;
    cin >> A >> B;
    cout << max(A - 2 * B, 0LL) << endl;
    return 0;
}

Measured memory_bytes: 256
keys = list(map(str, input().split()))
values = list(map(int, input().split()))
rm_str = input()

dicts = {key: value for key, value in zip(keys, values)}
dicts[rm_str] = dicts[rm_str] - 1

print(' '.join([str(n) for n in list(dicts.values())]))


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

using namespace std;

template<class INT>
std::vector<INT> get_min_prime_fact_table(INT n){
    std::vector<INT> lp(n + 1), P;
    for (INT i = 2; i <= n; i++){
        if (lp[i] == 0){
            lp[i] = i;
            P.push_back(i);
        }
        for (INT j = 0; j <= P.size() and P[j] <= lp[i] and i * P[j] <= n; j++)
            lp[i * P[j]] = P[j];
    }

    return lp;
}

int main(){
    int x;
    cin >> x;
    auto lp = get_min_prime_fact_table<int>(1e6);
    int i = x;
    while (lp[i] != i) i++;
    cout << i << endl;
}

Measured memory_bytes: 4732
n=int(input())
for nn in range(n):
    x1,y1,x2,y2,x3,y3,x4,y4=list(map(float,input().split()))
    if x2-x1==0 or x4-x3==0:
        if x1==x2 and x3==x4:
            print("YES")
        else:
            print("NO")
    else:
        if abs((y2-y1)/(x2-x1)-(y4-y3)/(x4-x3))<10**-10:
            print("YES")
        else:
            print("NO")


Measured memory_bytes: 5632
import math

class BitIndexedTree:
	'''NOTES: 1-origin-indexed
	'''
	def __init__(self, itemCount):
		self.itemCount = itemCount
		self.items = [0 for i in range(itemCount+1)]

	def add(self, i,value):
		while i <= self.itemCount:
			self.items[i] += value
			i += (i & (-i))

	def sumFromStart(self, end):
		summary = 0
		i = end
		while i > 0:
			summary += self.items[i]
			i -= (i & (-i))
		return summary

	def sum(self, start,end):
		summary = self.sumFromStart(end) - self.sumFromStart(start-1)
		return summary

if __name__ == "__main__":
	MOD = 10 ** 9 + 7
	N=int(input())
	A=list(map(int,input().split()))

	BIT=BitIndexedTree(N)

	for n in range(N):
		BIT.add(n+1, A[n])

	ans = 0
	for n in range(N-1):
		# print(A[n],BIT.sum(n+2,N),A[n] * BIT.sum(n+2,N))
		# print(MOD)
		ans += ((A[n] * BIT.sum(n+2,N)) % MOD)


	print(ans % MOD)








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

double check(int a,int t,int k){
	int m;
	if(t >= k){
		m = 0;
	}else{
		for(int i = 1;i < 100;i++){
			t *= 2;
			if(t >= k){
				m = i;
				break;
			}
		}
	}
	double b = 1;
	for(int i = 1;i <= m;i++){
		b = b/2;
	}
	return (1.0/a)*b;
}

int main(){
	int n,k;
	cin >> n >> k;
	double ans = 0;
	for(int i = 1;i <= n;i++){
		ans += check(n,i,k);
	}
	printf("%.12f",ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] count = new int[N];
        while(in.hasNext()) {
            count[in.nextInt() - 1]++;
        }
        for(int i = 0; i < count.length; i++) {
            System.out.println(count[i]);
        }
    }
}


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

int main(){
    int a,b;
    cin>>a>>b;
    vector<int> s1;
    vector<int> s2;

    for(int i=0; i<b; i++){
        s1.push_back(a);
    }

    for(int i=0; i<a; i++){
        s2.push_back(b);
    }

    for(int i=0; i<min(a,b); i++){
        if(s1[i] > s2[i]){
            for(int j=0; j<s2.size(); j++) cout<<s2[j];
            cout<<endl;
            return 0;
        }
    }

    for(int i=0; i<s1.size(); i++) cout<<s1[i];
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;
int main()
{
	int n;
	cin >> n;
	vector<int> b(n-1);
	rep(i, n-1) cin >> b[i];
	ll sum = b[n - 2] + b[0];
	rep(i, n - 2) {
		sum += min(b[i], b[i + 1]);
	}
	cout << sum;
}

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

//atcoder
public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out, false);
        String[] weather = {"Sunny", "Cloudy", "Rainy"}; 
        String input = scanner.next();
        for(int i= 0; i < 3; i++) {
            if (input.equals(weather[i])) {
                out.println(weather[(i+1)%3]);
                break;
            }
        }
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

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

    string ans = "No";
    if (a == b && b != c) ans = "Yes";
    else if (a == c  && c != b) ans = "Yes";
    else if (b == c && c != a) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){
	long long x;
	scanf("%lld",&x);
	if(x%11>6) printf("%lld\n",(x/11)*2+2);
	else if (x%11>0) printf("%lld\n",(x/11)*2+1);
	else printf("%lld\n",(x/11)*2);
	return 0;
}

Measured memory_bytes: 128
import collections

H, W, K = map(int, input().split())

S = [[sign for sign in input()] for i in range(H)]

ans = [[] for i in range(H)]
count = 0
flag = True
empty_cnt = 0

for i, row in enumerate(S):
    C = collections.Counter(row)
    str_cnt = C["#"]
    
    # 1列にイチゴがないときは直前の列と同じ分割にすればよいが……
    if str_cnt == 0:
        # 以前の列に数字が入っていないときは以後の列と同じにしたい
        if i == 0 or ans[i-1] == []:
            # 先頭から何列目までが保留になっているかカウント
            flag = False
            empty_cnt += 1
        else:
            ans[i] = ans[i-1]
            
    # 1列にイチゴがあるときはイチゴが来るたびにカットを入れる（イチゴの個数-1回）
    else:
        count += 1
        buf = 0
        for sign in row:
            ans[i].append(count)
            if sign == "#" and buf < str_cnt - 1:
                count += 1
                buf += 1
    
# 保留になっている先頭分を埋める
if not flag:
    for i in range(empty_cnt):
        ans[i] = ans[empty_cnt]
    flag = True

# 出力
for row in ans:
    print(*row)

Measured memory_bytes: 50652
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
int n;
int a[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	sort(a,a+n);
//	for(int i=0;i<n;i++)
//		printf("%d ",a[i]);
//	printf("\n");
//	system("pause");
	int reachx,reachy;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=(n-i))
		{
			reachx=i;
			reachy=n-i;
			break;
		}
	}
//	printf("%d %d\n",reachx,reachy);
//	printf("%d\n",a[reachx]);
//	system("pause");
	bool noleft=(!reachx)||(a[reachx-1]<reachy);
	bool noup=a[reachx]==reachy;
//	cout<<noleft<<" "<<noup<<endl;
	if(noleft&&noup)
	{
		printf("Second\n");
	}
	else if(noleft)
	{
		int up=a[reachx]-reachy;
		if(up&1)printf("First\n");
		else printf("Second\n");
	}
	else if(noup)
	{
		int lft=reachx-1;
		int clft=0;
		while(lft>=0&&a[lft]==a[reachx])
		{
			lft--;
			clft^=1;
		}
	//	cout<<clft<<endl;
		if(clft)printf("First\n");
		else printf("Second\n");
	}
	else
	{
		int up=a[reachx]-reachy;
	//	cout<<up<<endl;
		up&=1;
		int lft=reachx-1;
		int clft=0;
		while(lft>=0&&a[lft]==reachy)
		{
			lft--;
			clft^=1;
		}
	//	cout<<lft<<" "<<reachx<<" "<<a[lft]<<endl;
	//	cout<<up<<" "<<clft<<endl;
		if(up||clft)printf("First\n");
		else printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int r, g;
  cin >> r >> g;
  out(2 * g - r);
}
int main(void) { solve(); }


Measured memory_bytes: 3612
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  double X, Y, a, b, c;
  cin >> X >> Y;
  a = (X * 4.0 - Y)/2.0;
  b = fmod(a, 1);
  if (4.0 * X < Y) {
    cout << "No" << endl;
  }
  else if (2.0 * X > Y) {
    cout << "No" << endl;
  }
  else if (2.0 * X <= Y && 4.0 * X >= Y && b == 0.0) {
      cout << "Yes" << endl;
    }
  else {
      cout << "No" << endl;
    }
  }    


Measured memory_bytes: 3844
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = numeric_limits<int>::max() / 2;

struct Edge
{
    int from, to, cost;
    Edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

// 単一始点最短経路 最悪O(EV) だが bellmann-ford より速い
// O(E) になったりならなかったりする. 負閉路もok
std::vector<int> spfa(const Graph &g, int s)
{
    int n = g.size();
    std::vector<int> d(n, INF);
    std::vector<int> in_q(n, 0), count(n, 0);
    std::queue<int> que;
    d[s] = 0;
    que.push(s);
    in_q[s] = 1;
    count[s]++;
    while (!que.empty())
    {
        int v = que.front();
        que.pop();
        in_q[v] = 0;
        for (const auto &e : g[v])
        {
            if (d[v] != INF && d[e.to] > d[v] + e.cost)
            {
                d[e.to] = d[v] + e.cost;
                if (!in_q[e.to])
                {
                    que.push(e.to);
                    in_q[e.to] = 1;
                    if (++count[e.to] >= n)
                    {
                        return std::vector<int>();
                    }
                }
            }
        }
    }
    return d;
}

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

    int V, E, r;
    cin >> V >> E >> r;
    Graph g(V);
    for (int i = 0; i < E; i++)
    {
        int s, t, d;
        cin >> s >> t >> d;
        g[s].push_back(Edge{s, t, d});
    }
    vector<int> d = spfa(g, r);
    if (d.size() == 0)
        cout << "NEGATIVE CYCLE" << endl;
    else
    {
        for (int i = 0; i < V; i++)
        {
            cout << (d[i] == INF ? "INF" : to_string(d[i])) << endl;
        }
    }
}


Measured memory_bytes: 3344
from collections import deque


H, W = [int(x) for x in input().split()]
Ch, Cw = [int(x) - 1 for x in input().split()]
Dh, Dw = [int(x) - 1 for x in input().split()]

warp_list = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2),
             (-1, -2), (-1, -1), (-1, 1), (-1, 2),
             (0, -2), (0, 2),
             (1, -2), (1, -1), (1, 1), (1, 2),
             (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]

maze = []
warp_count = []
for _ in range(H):
    line = list([x for x in input()])
    maze.append(line)
    warp_count.append([-1] * W)

queue = deque()
warp_queue = deque()

queue.appendleft((Ch, Cw, 0))
warp_count[Ch][Cw] = 0

answer = -1
warp_set = set()
while queue:
    def maze_check(h, w, use_magic):
        if h < 0 or H <= h:
            return False
        if w < 0 or W <= w:
            return False
        if warp_count[h][w] == -1:
            return True
        if warp_count[h][w] <= use_magic:
            return False

    def is_wall(h, w):
        if maze[h][w] == '#':
            return True
        return False

    now_h, now_w, use_magic = queue.pop()

    if now_h == Dh and now_w == Dw:
        if answer == -1:
            answer = use_magic

        elif answer > use_magic:
            answer = use_magic

        continue

    # 上下左右に移動
    for y, x in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
        if maze_check(now_h + y, now_w + x, use_magic):

            # 上下左右、いずれかに壁がある場合にはワープ先に行く可能性がある
            if is_wall(now_h + y, now_w + x):
                if not (now_h, now_w) in warp_set:
                    warp_queue.appendleft((now_h, now_w, use_magic))
                    warp_set.add((now_h, now_w))
            else:
                queue.appendleft((now_h + y, now_w + x, use_magic))
                warp_count[now_h + y][now_w + x] = use_magic

    if not queue:
        while warp_queue:
            now_h, now_w, use_magic = warp_queue.pop()

            for y, x in warp_list:
                warp_h = now_h + y
                warp_w = now_w + x

                if maze_check(warp_h, warp_w, use_magic+1):
                    if not is_wall(warp_h, warp_w):
                        queue.append((warp_h, warp_w, use_magic+1))
                        warp_count[warp_h][warp_w] = use_magic + 1
        warp_set = set()

print(answer)


Measured memory_bytes: 154056
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using namespace std;
int main(void){
  char n[4];
  cin >> n;
  int sw=0,check=7,a=n[0]-'0',b=n[1]-'0',c=n[2]-'0',d=n[3]-'0';
  for(int i=0;i<8;i++){
    if(sw==1)
      break;
    else{
    switch(i){
      case 0:
        if(check==a+b+c+d){
          cout << a << '+' << b << '+' << c << '+' << d << "=7\n";
          sw=1;
        }
        break;
      case 1:
        if(check==a+b+c-d){
          cout << a << '+' << b << '+' << c << '-' << d << "=7\n";
          sw=1;
        }
        break;
      case 2:
        if(check==a+b-c+d){
          cout << a << '+' << b << '-' << c << '+' << d << "=7\n";
          sw=1;
        }
        break;
      case 3:
        if(check==a+b-c-d){
          cout << a << '+' << b << '-' << c << '-' << d << "=7\n";
          sw=1;
        }
        break;
      case 4:
        if(check==a-b+c+d){
          cout << a << '-' << b << '+' << c << '+' << d << "=7\n";
          sw=1;
        }
        break;
      case 5:
        if(check==a-b+c-d){
          cout << a << '-' << b << '+' << c << '-' << d << "=7\n";
          sw=1;
        }
        break;
      case 6:
        if(check==a-b-c+d){
          cout << a << '-' << b << '-' << c << '+' << d << "=7\n";
          sw=1;
        }
        break;
      case 7:
        if(check==a-b-c-d){
          cout << a << '-' << b << '-' << c << '-' << d << "=7\n";
          sw=1;
        }
        break;
      default:
        break;
    }
  }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <numeric>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int N, M;
vector<int> L;
bool ok(int X){
  int firstsum = 0; // add L[0], L[1], ..., L[b - 1] to last block
  for(int b = 0; b < N; b++){ // begin index of first block
    if(firstsum > X) break;
    int rest = M; // rest of blocks
    int partial = 0; // sum of current block
    for(int i = b; i < N; i++){
      partial += L[i];
      if(partial > X){ // use next block
        partial = L[i];
        rest --;
        if(rest <= 0) break; // block shortage
      }
    }
    if(rest > 0 && partial + firstsum <= X) return true; // last block is not overflow

    firstsum += L[b]; // add L[b] to last block
  }
  return false;
}

int main(){
  while(cin>>N>>M && N){
    L.assign(N, 0);
    REP(i, N) scanf("%d", &L[i]);
    int S = accumulate(L.begin(), L.end(), 0);
    int lb = ceil(double(S) / M) - 1; // answer >= ceil(S / M)
    REP(i, N) lb = max(lb, L[i] - 1); // answer >= max(L[i])
    int ub = S; // answer <= S
    while(ub - lb > 1){
      int mid = (ub + lb) / 2;
      if(ok(mid)){
        ub = mid;
      }else{
        lb = mid;
      }
    }
    cout<<ub<<endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> a[100005];
int ans[100005];
void dfs(int no,int father){ 
	for (int i=0;i<a[no].size();i++){
		int u=a[no][i].first;
		int w=a[no][i].second%2; 
		if(u!=father){
         ans[u]=ans[no]^w;
         dfs(u,no);
       }
  }
}
int main(){
    int n;
	cin>>n;
	for (int i=1;i<n;i++){
		int u,v,c;
		cin>>u>>v>>c;
		a[u].push_back({v,c});
		a[v].push_back({u,c});
	}
	dfs(1,-1);
	for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int m;
    cin >> n >> m;
    vector<int>x(m);
    for(int i=0;i<m;i++)cin >> x[i];
    if(n>m){
        cout << 0;
        return 0;
    }
    sort(x.begin(),x.end());
    vector<int>lon_g(m);
    for(int i=0;i<m-1;i++){
        lon_g[i]=abs(x[i]-x[i+1]);
    }
    sort(lon_g.begin(),lon_g.end());
    reverse(lon_g.begin(),lon_g.end());
    int kyori=0;
    for(int i=0;i<n-1;i++)kyori+=lon_g[i];
    cout << x[m-1]-x[0]-kyori << endl;
}


Measured memory_bytes: 4056
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

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

    int *rec=new int[100001];
    for(int i=0;i<=100000;i++) rec[i]=0;

    vector<pair<int,int>> prog[31];
    for(int i=0;i<N;i++){
        int s,t,c;
        cin >> s >> t >> c;
        prog[c].push_back(make_pair(s,t));
    }
    for(int i=1;i<=C;i++){
        sort(prog[i].begin(),prog[i].end());
        for(int j=0;j<prog[i].size();j++){
            rec[prog[i][j].second]--;
            if(j>0 && prog[i][j-1].second==prog[i][j].first) rec[prog[i][j].first]++;
            else rec[prog[i][j].first-1]++;
        }
    }

    int max=0,cnt=0;
    for(int i=0;i<=100000;i++){
        cnt+=rec[i];
        if(max<cnt) max=cnt;
    }

    cout << max << endl;

    delete[] rec;
}

Measured memory_bytes: 1920
import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val t = in.readLine

  val n = 'z'-'a' + 1
  val ts = Array.fill(n)(-1)
  val tt = Array.fill(n)(-1)

  val isPosi = (0 until s.size).forall(i => {
    val a = s(i) - 'a'
    val b = t(i) - 'a'
    if(ts(a) != -1 || tt(b) != -1) {
      if(ts(a) != b || tt(b) != a) false
      else true
    }
    else {
      ts(a) = b
      tt(b) = a
      true
    }
  })

  val ans = if(isPosi) "Yes" else "No"
  println(ans)
}

Measured memory_bytes: 31372
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+1;
int n;
vector<int> q;
int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		int v=read();v=-v;
		int x=upper_bound(q.begin(),q.end(),v)-q.begin();
		if(x==q.size()) q.push_back(v);
		else q[x]=v;
	}printf("%d\n",q.size());
 	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define MAX 105000
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
ll ar[MAX];
void divisor(){
    for (int i = 1; i <= MAX; i++)
    {
        for (int j = i; j <= MAX;j+=i)
        {
            ar[j]++;
            
        }
        
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,m,x,c=0;
    ll a[MAX],ac[MAX];
    
    cin >> n >> m;
    string str;
    map<ll,ll>ma;ll p = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> x >> str;
        if(ac[x]==0 && str=="WA") a[x]++;
        else if(str == "AC" && ac[x]==0){
            c++;
            ac[x] = 1;
            p+=a[x];
        }
        
    }
    for(auto i:ma){
        p += i.second;
    }
    cout << c << " "<< p << endl;
}

Measured memory_bytes: 5112
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[100005];
int gcd(int x,int y)
{
    if (y==0) return x; else return gcd(y,x%y);
}
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    scanf("%d",&n);
    int k;
    scanf("%d",&k);
    int i;
    int gcds=0;
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        gcds=gcd(gcds,a[i]);
    }
    sort(a,a+n);
    if (a[n-1]==k)
    {
        puts("POSSIBLE");
        return 0;
    }
    if (a[n-1]<k)
    {
        puts("IMPOSSIBLE");
        return 0;
    }
    if (k%gcds==0)
    {
        puts("POSSIBLE");
    }
    else
    {
        puts("IMPOSSIBLE");
    }
    return 0;
} 


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

class Dice {
public:
    Dice() { reset(); };
    void reset() {top = 1; front = 2; side = 3;}

    int top;
    int front;
    int side;
    int move(char op[]);
    // void show() { printf("%d %d %d\n", top, front, side); };

private:
    const int SUM = 7;
    void swap(int *a, int *b);
};

void Dice::swap(int *a, int *b) {
    int tmp = *a; 
    *a = SUM - *b;
    *b = tmp;
}

int Dice::move(char op[]) {
    if      (strcmp(op, "North") == 0 ) swap(&this->front, &this->top   );
    else if (strcmp(op, "East")  == 0 ) swap(&this->top,   &this->side  );
    else if (strcmp(op, "West")  == 0 ) swap(&this->side,  &this->top   );
    else if (strcmp(op, "South") == 0 ) swap(&this->top,   &this->front );
    else if (strcmp(op, "Right") == 0 ) swap(&this->side,  &this->front );
    else if (strcmp(op, "Left")  == 0 ) swap(&this->front, &this->side  );
    return this->top;
}

int main () {
    Dice dice;
    char op[10];
    int n, sum;

    while (1) {
        scanf("%d", &n);
        if (n == 0) break;

        sum = 1;
        dice.reset();
        while(n--) {
            scanf("%s", op);
            // printf("%s: ", op); dice.move(); dice.show();
            sum += dice.move(op);
        }
        printf("%d\n", sum);
    }

    return 0;
}

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

int main() {
  int A,B,C,D;
  
  cin >> A >> B >> C >> D;
  
  int L = A+B , R = C+D;

  if (L>R) {
    cout << "Left" << endl;
  }
  else if(L==R){
    cout << "Balanced" << endl;
  }
  else if(L<R){
    cout << "Right" << endl;
  }
  
}


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

int main()
{
	int sum=0;
	string s, t;
	getline(cin, s);
	getline(cin, t);
	
	for(int i=0; i<s.size(); ++i)
	{
		if(s[i]!=t[i])
		{
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3896
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <queue>
#include <cctype>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <iomanip>
//#include <bits/stdc++.h>


#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define IFOR(i,a,b) for(int i=(a);i>=(b);--i)

using namespace std;

typedef long long lolo;
typedef pair<int, int> pii;
typedef unsigned long long ulolo;

const int maxn = 100000 + 5;
const int maxm = 300005;
const int INF = 0x3f3f3f3f;
const lolo inf = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
const int MOD = (int)1e9+9;

template<class T>
inline void read(T &x) {
    x = 0; T flag = 1;char c;
    do { c = (char) getchar(); if (c == '-') break; } while (c < '0' || c > '9');
    if (c == '-') c = '0', flag = -1;
    do { x = x * 10 + c - '0';c = (char) getchar();} while (c >= '0' && c <= '9');
    x *= flag;
}
template<class T>
inline void out(T x) {
    if (x > 9) out(x / 10);
    x = x % 10;
    putchar('0' + x);
}

int main(){
//    freopen("../in.txt","r",stdin);
    int n;
    set<char> k;
    read(n);
    char ch[2];
    FOR(i,1,n) {
        scanf("%s",ch);
        k.insert(ch[0]);
    }
    puts(k.size()==3?"Three":"Four");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
         
    int main() {
        int N;
        cin >> N;
        
        vector<int> vec(N);
        for (int i = 0; i < N; i++) {
            cin >> vec.at(i);
        }

        for (int i = 0; i < N; i++){
            if(vec.at(i) % 2 == 0 && vec.at(i) % 3 != 0 && vec.at(i) % 5 != 0){
                cout << "DENIED" << endl;
                return(0);
            }
        }
        
        cout << "APPROVED" << endl;
        return(0);

        }

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

using namespace std;

const int N = 2e2 + 5;
const int LG = 32;

int nidx = 2;

struct OPT {
  int id;
  OPT( int id ):id( id ) {} OPT(){}
  OPT operator + ( const OPT & rhs ) const {
    printf("+ %d %d %d\n",id,rhs.id,++nidx);
    return OPT( nidx );
  }
  OPT operator < ( const OPT & rhs ) const {
    printf("< %d %d %d\n",id,rhs.id,++nidx);
    return OPT( nidx );
  }
};

const OPT A( 0 ) , B( 1 ) , ed( 2 ) , _0( int(2e5) );

OPT bin[N] , Bbin[N] , a , b , c , res[N] , Abin[N];

int main( void ) {
  puts("39469");
  bin[0] = ed < ( A + B );
  for( int i = 1 ; i <= LG ; ++i )
    bin[i] = bin[i - 1] + bin[i - 1];
  a = OPT( ++nidx );
  for( int i = LG ; ~i ; --i ) {
    b = B + bin[0];
    c = a + bin[i];
    Bbin[i] = c < b;
    c = Bbin[i];
    for( int j = 1 ; j <= i ; ++j )
      c = c + c;
    a = a + c;
  }
  a = OPT( ++nidx );
  for( int i = LG ; ~i ; --i ) {
    b = A + bin[0];
    c = a + bin[i];
    Abin[i] = c < b;
    c = Abin[i];
    for( int j = 1 ; j <= i ; ++j )
      c = c + c;
    a = a + c;
  }
  for( int i = 0 ; i <= LG ; ++i )
    for( int j = 0 ; j <= LG ; ++j ) {
      OPT tmp = Abin[i] + Bbin[j];
      tmp = bin[0] < tmp;
      for( int k = 1 ; k <= i + j ; ++k )
        tmp = tmp + tmp;
      printf("+ 2 %d 2\n",tmp.id);
    }
}


Measured memory_bytes: 3692
int main(void)
{
  int plus=0,sub=0,mul=0;
  int a, b, ans;
  
  scanf("%d%d",&a ,&b);
  plus = a+b;
  sub = a-b;
  mul = a*b;
  
  ans = plus;
  if(ans < sub)
    ans = sub;
  if(ans < mul)
    ans = mul;
  printf("%d", ans);
  
  return(0);
}

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

int H;
vector<int> A;

void MaxHeapi(int i) {
  int l = 2 * i, r = 2 * i + 1, largest;
  if (l <= H && A[l] > A[i])
    largest = l;
  else
    largest = i;
  if (r <= H && A[r] > A[largest])
    largest = r;

  if (largest != i) {
    swap(A[i], A[largest]);
    MaxHeapi(largest);
  }
}

void BuildMaxHeap() {
  for (int i = H / 2; i >= 1; --i)
    MaxHeapi(i);
}

int main() {
  cin >> H;
  A.resize(H + 1);
  for (int i = 1; i <= H; ++i)
    cin >> A[i];

  BuildMaxHeap();

  for (int i = 1; i <= H; ++i)
    cout << ' ' << A[i];
  cout << endl;
}


Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

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

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int, int> > vp;

typedef long long ll;
int main(){
  while(1){
  	int n;
  	int s[10100];
  	int e[10100];
  	cin >> n;
  	if(n==0) break;
  	rep(i,n*2){
  		string str;
  		cin >> str;
  		
  		//??????????????°????????????
  		int hh = (char(str[0])-'0')*10+char(str[1])-'0';
  		int mm = (char(str[3])-'0')*10+char(str[4])-'0';
  		int ss = (char(str[6])-'0')*10+char(str[7])-'0';
  		// cout << hh << "mm" << mm << "ss"<<ss << endl;
  		int time = hh*3600+mm*60+ss;
  		if(i%2==0) s[i/2] = time;
  		else e[i/2] = time;
  	}
  	sort(s,s+n);
  	sort(e,e+n);
  	int sp = 0;
  	int ep = 0;
  	int ans = 0;
  	int tm = 0;
  	rep(i,n*2){
  		if(sp!=n&&(ep==n||s[sp]<e[ep])){
  			ans++;
  			sp++;
  			// cout << "a";
  		}else{
  			ans--;
  			ep++;
  			// cout << "b";
  		}
  		tm = max(tm,ans);
  		// cout <<endl << "tm:" <<tm << endl;
  	}
  	cout << tm << endl;

  }
  return 0;
}

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

const int MAXN = 1e6+10;
int A[MAXN],n;

int binarySearch(int key){
	int left = 0;
	int right = n;
	int mid;
	while(left<right){
		mid = (left+right)/2;
		if(key==A[mid])	return 1;
		if(key>A[mid])	left = mid+1;
		else if(key<A[mid])	right = mid;
	}
	return 0;
}

int main(){
	int i,q,k,sum=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}

	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&k);
		if(binarySearch(k))	sum++;
	}
	printf("%d\n",sum);

	return 0;
}




Measured memory_bytes: 3488
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(void){
  int a,b,i;

  scanf("%d %d",&a,&b);
  for(i=1;i<4;i++){
    if((a*b*i)%2!=0){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");


  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define range(i,b) rep(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
	int map[16][16];
	int i,j;
	int a,b;
	int n;

	while(cin >> n, n){
		i = 1;
		a = n / 2 + 1;
		b = n / 2;
		int map[15][15] = {{0}};
		while(i <= n * n){
			if(a >= n){
				a = 0;
			}
			if(b >= n){
				b = 0;
			}else if(b < 0){
				b = n - 1;
			}
			if(map[a][b] != 0){
				a++;
				b--;
				continue;
			}
			map[a][b] = i;
			i++; a++; b++;
		}
		range(k,n){
			range(j,n){
				printf("%4d",map[k][j]);
			}
			cout << endl;
		}
	}

}

Measured memory_bytes: 1192
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
#define PI 3.14159265358979323846
int main(){
	int a, b; cin >> a >> b;
	cout << ((a<=9 && b<= 9) ? a*b : -1);
	//getchar();
	//getchar();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct TTL{
	int x,v;
}p[200010];
const int mod=1000000007;
int L[200010],R[200010];
int f[200010],q[200010];
int lsh[600010],cnt;
int read()
{
	int ans=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') ans=ans*10+ch-'0',ch=getchar();
	return ans;
}
bool cmp(TTL a,TTL b)
{
	return a.x<b.x;
}
int ycl()//左边最大 右边最小 
{
	int maxn=0,minn=2e9;
	for (int i=1;i<=n;i++)
	{
		maxn=max(maxn,p[i].v);
		R[i]=maxn;
		lsh[++cnt]=maxn;
	}
	for (int i=n;i>=1;i--)
	{
		minn=min(minn,p[i].v);
		L[i]=minn;
		lsh[++cnt]=minn;
	}
///	for (int i=1;i<=n;i++)
//		printf("%d %d\n",L[i],R[i]);
}
void plu(int &a,int b)
{
	a+=b;
	if (a>=mod) a-=mod;
}
void jian(int &a,int b)
{
	a-=b;
	if (a<0) a+=mod;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++)
		p[i].x=read(),p[i].v=read(),lsh[++cnt]=p[i].v;
	sort(p+1,p+1+n,cmp);
	ycl();
	sort(lsh+1,lsh+1+cnt);
	cnt=unique(lsh+1,lsh+1+cnt)-1-lsh;
	for (int i=1;i<=n;i++)
	{
		L[i]=lower_bound(lsh+1,lsh+1+cnt,L[i])-lsh;
		R[i]=lower_bound(lsh+1,lsh+1+cnt,R[i])-lsh;
	//	printf("%d %d\n",L[i],R[i]);
	}
	int head=0,tail=1;
	int sum=1;
	L[0]=0;R[0]=0;f[0]=1;
	n++;
	L[n]=n;R[n]=n;
	for (int i=1;i<=n;i++)
	{
		while (head<tail&&L[i]>R[q[head+1]]+1)
			jian(sum,f[q[head+1]]),head++;
		f[i]=sum;
		plu(sum,f[i]);
		q[++tail]=i;
	//	cout<<sum<<endl;
	}
	printf("%d",f[n]);
} 

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define fir first
#define sec second
#define db double
#define ll long long
#define ev eg[i].v
#define pb push_back
#define mod 1000000007
#define pir pair<int,int>
#define Rep(i,l,r) for(int i=(l);i<=(r);++i)
#define RepD(i,r,l) for(int i=(r);i>=(l);--i)
#define RepG(i,x) for(int i=hd[x];i;i=eg[i].nxt)
using namespace std;

const int N=6e5+5;

char s[N];int f[N][8];
int g[8][2]={{2,1},{4,3},{6,5},{3,3},{7,1},{2,1},{2,2},{4,4}};

int main(){
	scanf("%s",s);
	int len=strlen(s);
	f[0][0]=1;
	Rep(i,0,len-1)
		Rep(j,0,7){
			if(s[i]!='0') f[i+1][g[j][1]]=(f[i+1][g[j][1]]+f[i][j])%mod;
			if(s[i]!='1') f[i+1][g[j][0]]=(f[i+1][g[j][0]]+f[i][j])%mod;
		}
	printf("%d\n",(f[len][1]+f[len][3])%mod);
	return 0;
}

Measured memory_bytes: 10752
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    int ans = 1e9;
    for (int i = 0; i < len - 2; i++) {
        string sub = s.substr(i, 3);
        int tmp = stoi(sub);
        ans = min(ans, abs(tmp - 753));
    }
    cout << ans << endl;
}


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

int main () {
    string S;
    cin >> S;
    int n = S.length();
    long long res = 0;
    for(int i = 0; i< (1 << n -1); i++) {
        long long tmp = 0;
        for(int j = 0; j<n; j++) {
            tmp = tmp * 10 + S[j] - '0';
            if(i & (1 << j)) {
                res += tmp;
                tmp = 0;
            }
        }
        res += tmp;
    }
    printf("%ld", res);
}

Measured memory_bytes: 256
from collections import*
import sys
input=sys.stdin.readline


class UNION_FIND(object):
    def __init__(self,n):
        #親の番号を格納する。親だった場合は-(その集合のサイズ)
        #作るときはParentの値を全て-1にする
        #こうすると全てバラバラになる
        self.parent=[-1 for i in range(n)]
        
    def root(self,x):
        #Aがどのグループに属しているか調べる
        if self.parent[x]<0:
            return x
        else:
            self.parent[x]=self.root(self.parent[x])  #親を再帰で探知 再帰は最後に上のifにひっかかる
            return self.parent[x]
 
    def size(self,x):
        #自分のいるグループの頂点数を調べる
        return -self.parent[self.root(x)]   #親をとってきたい
        
    def union(self,x,y):
        #AとBをくっ付ける
        #AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        #print(self.parent)
        x=self.root(x)
        y=self.root(y)
        #print(x,y)
        if x==y:   #すでにくっついてるからくっ付けない
            return False
            
        #大きい方(A)に小さいほう(B)をくっ付けたい
        #大小が逆だったらひっくり返しちゃう。
        if self.size(x)<self.size(y):
            x,y=y,x
        self.parent[x]+=self.parent[y]  #Aのサイズを更新する
        self.parent[y]=x   #Bの親をAに変更する
        return True
        
n,k,l=map(int,input().split())
u1=UNION_FIND(n)
u2=UNION_FIND(n)
d=defaultdict(int)
for i in range(k):
    p,q=map(int,input().split())
    u1.union(p-1,q-1)
for i in range(l):
    p,q=map(int,input().split())
    u2.union(p-1,q-1)
for i in range(n):
    d[(u1.root(i),u2.root(i))]+=1
print(*[d[(u1.root(i),u2.root(i))]for i in range(n)])

Measured memory_bytes: 41472