akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	int n,m;
	cin >> n >> m;
	vector<vector<int>> v(m, vector<int>());
	cu(i,0,m){
		int k,x;
		cin >> k;
		while(k--){
			cin >> x;	
			v[i].pb(x);
		}
	}
	vector<int> p(m);
	cu(i,0,m)cin >> p[i];
	int ans = 0;
	cu(i,0,1 << n){
		
		bool val = true;
		cu(j,0,m){
			int sum = 0;
			cu(k,0,v[j].size()){
				sum ^= (i >> (v[j][k]-1)) & 1;
			}
			if(sum != p[j]){val = false;break;}
		}
		ans += val;
	}
	cout << ans << '\n';
}


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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        int E = scan.nextInt();
        int F = scan.nextInt();
        int max_total = 0;
        int max_salt = 0;
        double max_percentage = -1;
        for (int i = 0; i * 100 * A <= F; i++) {
            for (int j = 0; j * 100 * B <= F - i * 100 * A; j++) {
                int water = i * 100 * A + j * 100 * B;
                if (water == 0) {
                    continue;
                }
                int max_ok_salt = water / 100 * E;
                double percentage = 0;
                if (max_percentage < percentage) {
                    max_percentage = percentage;
                    max_total = water;
                    max_salt = 0;
                }
                for (int k = 0; k * C <= F - water; k++) {
                    for (int l = 0; l * D <= F - water - k * C; l++) {
                        int salt = k * C + l * D;
                        if (max_ok_salt < salt) {
                            continue;
                        }
                        percentage = (double) salt * 100 / (water + salt);
                        if (max_percentage < percentage) {
                            max_percentage = percentage;
                            max_total = water + salt;
                            max_salt = salt;
                        }
                    }
                }
            }
        }
        System.out.println(max_total + " " + max_salt);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

int main () {
	int n, m;
	cin >> n >> m;
	int masa[n], value[n];
	long long dp[m+1], ans = 0;
	memset(dp, -1, sizeof dp);
	dp[0] = 0;
	
	for (int i=0; i<n; i++){
		cin >> masa[i] >> value[i];	
		for (int j=m-masa[i]; j>=0; j--){
			if(dp[j] == -1) continue;
			dp[masa[i]+j] = max(dp[masa[i]+j], dp[j]+value[i]);
			ans = max(ans, dp[masa[i]+j]);
		}
	}
	
	cout << ans;
return 0;
}



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

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

using namespace std;

int n,cost,limit;
map<vector<int>,int> memo;
vector<vector<int> > LOOP;

int dfs(int cur,int cnt,vector<int> &remain){

  if( cur >= limit ) {
    return cnt;
  }

  if( memo.find(remain) != memo.end() ) return memo[remain];

  vector<int> tmp = remain;
  bool update = true;
  int ret = cnt;
  while( update ){
    ret = max(ret,dfs(cur+1,cnt,remain));
    cnt++;
    REP(i,1,10) {
      remain[i] -= LOOP[cur][i];
      if( remain[i] < 0 ) {
        update = false;
        break;
      }
    }
  }
  remain = tmp;
  return memo[remain] = ret;
}

void precalc(int value,int sum,vector<int> &vec) {
  if( value >= 10 ) {
    if( sum == 10 ) LOOP.push_back(vec);
    return;
  }
  rep(i,11){
    if( sum + i * value > 10 ) break;
    vec[value] = i;
    precalc(value+1,sum+i*value,vec);
    vec[value] = 0;
  }
  return;
}

int main() {

  vector<int> buf(10,0);
  precalc(1,0,buf);
  sort(LOOP.begin(),LOOP.end());

  while( scanf("%d",&n), n ) { 
    memo.clear();
    vector<int> remain;
    remain.resize(10);
    cost = limit = 0;
    int coef = 0,input;
    rep(i,n) {
      scanf("%d",&input);
      if( input == 10 ) coef++;
      if( input >= 10 ) continue;
      remain[input]++;
    }

    REP(i,1,5) {
      int tmp = min(remain[i],remain[10-i]);
      coef += tmp;
      remain[i] -= tmp, remain[10-i] -= tmp;
    }
    int tmp = remain[5] / 2;
    coef += tmp, remain[5] -= 2*tmp;
    limit = LOOP.size();

    printf("%d\n",coef + dfs(0,0,remain));

  }
  return 0;
}

Measured memory_bytes: 7604
#include <iostream>

int main () {
    
    int x, y;
    while(std::cin >> x >> y, x != 0 || y != 0) {
        if (x < y) std::cout << x << " " << y << std::endl;
        else std::cout << y << " " << x << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

void cout_vector(vector<int>, int);

void insertion_sort(vector<int> vec, int n) {
    rep(i,n-1) {
        int v = vec.at(i+1);
        int j = i;
        while (j >= 0 && vec.at(j) > v) {
            vec.at(j+1) = vec.at(j);
            j--;
        }
        vec.at(j+1) = v;
        cout_vector(vec, n);
    }
}

void cout_vector(vector<int> vec, int n) {
    rep(i,n-1) {
        cout << vec.at(i) << " ";
    }
    ct(vec.at(n-1));
}

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec.at(i);
    cout_vector(vec, n);
    insertion_sort(vec, n);
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  vector<int> a(n), b(n);
  for (auto &i : a) cin >> i;
  for (auto &i : b) cin >> i;
  int ans = 0, need = 0;
  vector<int> redu;
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) redu.push_back(a[i] - b[i]);
    if (a[i] < b[i]) {
      need += b[i] - a[i];
      ans++;
    }
  }
  sort(all(redu));
  while (need > 0 && redu.size()) {
    need -= redu.back();
    redu.pop_back();
    ans++;
  }
  if (need > 0) cout << -1 << '\n';
  else cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 5456
#include <iostream>
#include <stdio.h>
using namespace std;
int a[151];
int main()
{
	for(int n;cin>>n;)
	{
		if(n==0)
			break;
		int i,j,k;
		for(i=1;i<=n;++i)
			cin>>a[i];
		int m1=1,m2=1,num=0,an=1;
		for(i=2;i<=n;++i)
		{
			if(a[i]!=a[m2]+1)
			{
				if(num>0)
					cout<<" ";
				if(an==1)
					cout<<a[m1];
				else cout<<a[m1]<<"-"<<a[m2];
				num++;
				m1=i;m2=i;
				an=1;
			}
			else {m2++;an++;}
			if(i==n)
			{
				if(num>0)
					cout<<" ";
				if(an==1)
					cout<<a[m1];
				else cout<<a[m1]<<"-"<<a[n];
			}
		}
		if(n==1)
			cout<<a[1];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
const int INF = 1e9+7;

int main(int argc, char **argv)
{
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d %d %.5f\n", a/b, a%b, (double)a / b);
	return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

int solve(int n, vi &a, vi &b){
  vi dp(n+1);
  rep(i, 0, n+1) dp[i] = i;

  rep(i, 0, n){
    rep(j, 0, 3){
      if(i+a[j] <= n){
        chmax(dp[i+a[j]], dp[i] + b[j]);
      }
    }
  }

  int res = 0;
  rep(i, 0, n+1) chmax(res, dp[i]);
  return res;
}

signed main(){
  int n;
  cin >> n;

  vvi a(2, vi(3));
  rep(i, 0, 2) rep(j, 0, 3) cin >> a[i][j];

  int m = solve(n, a[0], a[1]); 
  int ans = solve(m, a[1], a[0]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF = 2'000'000'000;

int main() {
  int h[2], m[2], k;
  cin >> h[0] >> m[0] >> h[1] >> m[1] >> k;

  int total = 60*(h[1]-h[0]) + m[1] - m[0];

  cout << max(0, total-k) << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const double eps = (1e-14);

int main(){
  long double a, b, c;
  cin >> a >> b >> c;
  
  long double sum = sqrt(a) + sqrt(b);
  
  if (sum + eps < sqrt(c)){
    cout << "Yes";
  }
  else {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 764
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

int N, M, K, H, W, L, R;


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

	cin >> N;
	while(N){
	for (int i = 0; i < 9; i++) {
		cin >> M;
		N -= M;
	}
	cout << N << endl;
	cin>>N;
	}
	return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll P=998244353;
ll dp[3002][3002],dp2[3002][3002];
int main()
{
    ll t,i,j,k,l,m,n,o,p,q,r,s,a[300002],prefix[300001]={0};
    cin>>n>>s;
    for(i=1;i<=3001;i++)
    {
      for(j=1;j<=3001;j++)
      dp[i][j]=0;
    }
    for(i=1;i<=n;i++)
    {
    cin>>a[i];
    }
    ll ans=0;
    ll res=0;
    ll MOD=998244353;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=s;j++)
        {
                          dp[i][j]+=dp[i-1][j];
            if(j+a[i]<s){
                if(j==0){;
                    dp[i][j+a[i]]+=i;
                    dp[i][j+a[i]]%=MOD;
                }
                else{
                    dp[i][j+a[i]]+=dp[i-1][j];
                    dp[i][j+a[i]]%=MOD;
                }
            }
            else{
                if(j+a[i]==s){
                    if(j==0){
                        res+=(ll)(i)*(n-i+1);
                        res%=MOD;
                    }    
                    else{
                        res+=dp[i-1][j]*(n-i+1);
                        res%=MOD;
                    }
                }
            }
        }
    }
         
          cout<<res<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int n, q;
	cin >> n;
	vector<ll> s(n);
	rep(i, n){
		int p;
		scanf("%d", &p);
		s.at(i) = p;
	}
	cin >> q;
	vector<ll> t(q);
	rep(i, q){
		int p;
		scanf("%d", &p);
		t.at(i) = p;
	}
	int c = 0;
	sort(t.begin(), t.end());
	int i = q-1;
	int j = 0;
	int Mn = n-1;
	int mn = 0;
	while(i >= 0){
		int Mk = Mn;//Mnは最大番号、mnは最小番号
		int k = (Mn-mn)/2+mn;
		int mk = mn;
		while(1){//iはこの時点で最大の数
			int check = s.at(k);
			if(check > t.at(i)){
				Mk = k;
				k = (Mk-mk)/2+mk;
				Mn = k;//Mkが更新されるたびにMnも更新
			}else if(check < t.at(i)){
				mk = k;
				k = (Mk-mk)/2+mk;
			}else if(check == t.at(i)){
				c++;
				Mn = k;
				break;
			}
			if(mk == k){
				if(s.at(Mk) == t.at(i)){
					c++;
					Mn = Mk;
					break;
				}else if(s.at(k) == t.at(i)){
					c++;
					Mn = k;
					break;
				}else{
					break;
				}
			}
		}
		i--;// iを減らす
		/*if(i == j) break;
		Mk = Mn;
		k = (Mn-mn)/2+mn;
		mk = mn;
		while(Mk != mk){//ｊはこの時点で最小
			int check = s.at(k);
			if(check > t.at(j)){
				Mk = k;
				k = (Mk-mk)/2+mk;
			}else if(check < t.at(j)){
				mk = k;
				k = (Mk-mk)/2+mk;
				mn = k;//ｍｋが更新されるたびにmｎも更新
			}else if(check == t.at(j)){
				c++;
				mn = k;
				break;
			}
			if(mk == k){
				if(s.at(Mk) == t.at(j)){
					c++;
					mn = Mk;
					break;
				}else if(s.at(k) == t.at(j)){
					c++;
					mn = k;
					break;
				}else{
					break;
				}
			}
		}
		j++;*/
	}
	cout << c << endl;
}



Measured memory_bytes: 3880
def prepare(n, MOD):
    f = 1
    factorials = [1] * (n + 1)
    for m in range(1, n + 1):
        f = f * m % MOD
        factorials[m] = f
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv = inv * m % MOD
        invs[m - 1] = inv

    return factorials, invs


def get_nhr(n, facts, invs, MOD):
    def nhr(r):
        return facts[n + r - 1] * invs[r] * invs[n - 1] % MOD

    return nhr


def solve(n, m):
    MOD = 998244353
    facts, invs = prepare(n + 3 * m, MOD)
    fn = facts[n]
    nhr = get_nhr(n, facts, invs, MOD)
    nm2 = min(n, m - 1)
    ans = 0
    for odd in range(m % 2, min(m, n) + 1, 2):
        tmp = nhr((3 * m - odd) // 2)
        if odd > 0:
            tmp -= odd * nhr((m - odd) // 2)
        if odd < nm2:
            tmp -= (n - odd) * nhr((m - odd - 2) // 2)
        ans = (ans + fn * invs[odd] * invs[n - odd] % MOD * tmp) % MOD
    return ans


n, m = list(map(int, input().split()))
print(solve(n, m))


Measured memory_bytes: 200820
#include <string>
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;


int main () {

    double N, K;
    cin>>N>>K;
    double prob_above = 0;
    double prob_below = 0;
    int max = N;
    if(N>=K){
        prob_above = ((N-K+1))/(N);
        max = K-1;
    }

    for(int i=1; i<=max; i++){
        prob_below+=(1.0f/N)*pow(1.0f/2.0f, ceil(log2(double(K)/i)));
    }
    cout<<std::setprecision(10)<<prob_above+prob_below<<endl;

    return 0;

}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int K;
    int even, odd;
    int count = 0;

    scanf("%d", &K);

    for(even = 2; even <= K; even += 2){
        for(odd = 1; odd <= K; odd += 2){
           count += 1;
           // printf("(%d, %d)\n", even, odd);
        }
    }

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

    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
using namespace std;
int bank6[6] = {6,36,216,1296,7776,46656};
int bank9[5] = {9,81,729,6561,59049};
int bank(int N,int ans);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N = 0;
    cin >> N;
    int ans = 0;
    int i = 0;
    ans = bank(N,0);
    cout << ans << endl;
    return 0;
}

int bank(int N,int ans){
    int i = 0;
    int ans6 = 0;
    int ans9 = 0;
    for(i=5;i>=0;i--){
        if(N>=bank6[i]){
            ans6 = bank(N-bank6[i],ans+1);
            break;
        }else if(i==0){
            ans6 = N+ans;
        }
    }
    for(i=4;i>=0;i--){
        if(N>=bank9[i]){
            ans9 = bank(N-bank9[i],ans+1);
            break;
        }else if(i==0){
            ans9 = N+ans;
        }
    }
    return min(ans6,ans9);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;
int main(void){
    int n;
    cin>>n;
    set<int> s;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            long n = ILongs()[0];
            long[][] a = ILongLongs(n);
            long mx = 0;
            long mx2 = 0;
            for(long i =0;i<n;i++){
                if(a[i][0]>mx){mx = a[i][0];
                }else{
                    if(a[i][0]>mx2){
                        mx2 = a[i][0];
                    }
                }
            }
            for(int i=0;i<n;i++){
                if(a[i][0]==mx){
                    Console.WriteLine(mx2);
                }else{
                    Console.WriteLine(mx);
                }
            }
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

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

int main(int argc , char* argv[]){
	int n; cin >> n;
	vector<int> p(n);
	for(int i=0;i<n;++i) cin >> p[i];
	int counter=0;
	for(int i=1;i<n-1;++i){
		if((p[i]>p[i-1]&&p[i]<p[i+1])|| (p[i]>p[i+1]&& p[i]<p[i-1])) ++counter;
	}
	cout << counter << endl;
}
	
		

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#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 prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

bool plane = true;
set<int> xaxis, yaxis;

void dp( set<int> &axsis, int d) {
    if (d==0) return;
    set<int> nxt;
    
    if(plane) {
        for(auto a : axsis) {
            nxt.insert( a+d );
        }
    } else {
        for(auto a : axsis) {
            nxt.insert( a+d );
            nxt.insert( a-d );
        }
    }
    swap(axsis,nxt);
}

int main() {
    string s;
    int x, y;
    xaxis.insert(0);
    yaxis.insert(0);
    
    cin >> s >> x >> y;
    
    int f=0;
    int direc = 1;  // 1でx軸方向,2でy軸方向
    rep(i,s.size()) {
        if(s[i]=='F')f++;
        else {
            dp( direc==1?xaxis:yaxis ,f);
            direc = 1-direc;
            f=0; plane=false;
        }
    }
    dp( direc==1?xaxis:yaxis ,f);
    
    if( xaxis.find(x)!=xaxis.end() && yaxis.find(y)!=yaxis.end() ) {
        cout1("Yes");
    } else {
        cout1("No");
    }
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) ); 
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll h; cin >> h;
  ll power2=1;
  ll i=0; 
  while(power2<=h){
    power2*=2;
  }
  cout << power2-1 << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nk = Input.ar;
        var xy = Enumerable.Repeat(0, nk[0]).Select(v => Input.arL).ToArray();
        var res = long.MaxValue;
        var xar = xy.Select(v => v[0]).OrderBy(v=>v).ToArray();
        var yar = xy.Select(v => v[1]).OrderBy(v=>v).ToArray();
        for (var xf = 0; xf < nk[0]; xf++)
            for(var xl=xf;xl<nk[0];xl++)
                for(var yf=0;yf<nk[0];yf++)
                    for(var yl = yf; yl < nk[0]; yl++)
                    {
                        var ct = 0;
                        for (var i = 0; i < nk[0]; i++)
                            if (xar[xf] <= xy[i][0] && xy[i][0] <= xar[xl] && yar[yf] <= xy[i][1] && xy[i][1] <= yar[yl])
                                ct++;
                        if(ct>=nk[1])
                        res = Min(res, (xar[xl] - xar[xf]) * (yar[yl] - yar[yf]));
                    }
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13524
n = int(input())
s = input()
l = []
if n==2:
    if s[0]==s[1]:
        print(1)
    else:
        print(0)
else:
    for i in range(1,len(s)-1):
        a = set(list(s[:i]))
        b = set(list(s[i:]))
        l.append(len(a & b))
    print(max(l))

Measured memory_bytes: 3060
//*********Abhay is awesome *************\

#include<bits/stdc++.h>


#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define piii pair<int,pii>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repc(i,a,n) for(int i=a;i<n;++i)
#define  repd(i,a,n) for(int i=a;i>n;--i)
#define int ll
using namespace std;
using ll = long long;
const ll N = 3*1e5 +5 ;
const ll mod = 1e9+7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
const double pi=3.14159265358979323846 ;
typedef vector<ll> vi;


void solve(){
	int r;
	cin>>r;
	double ans;
	ans = 2.0 * r * pi ;
	cout<<ans; 
	return;
}
	
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//#ifndef ONLINE_JUDGE
    // for getting input from input.txt
   //1 freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output1.txt", "w", stdout);
	//#endif
	solve(); 
	return  0;
}





Measured memory_bytes: 3804
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <cstring>
#include <climits>

#define RREP(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define INVREP(i,a,b) for(int i=a;i>=b;--i)
#define MOD 1000000007ll
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }//aに更新したいものを
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using ll = long long int;
//繰り返し2乗
ll modpow(ll N, ll P, ll M=MOD) {if (P == 0) return 1;if (P % 2 == 0) {ll t = modpow(N, P / 2, M);return t * t % M;}return (N * modpow(N, P - 1, M))%M;}
//階乗
pair<vector<ll>, vector<ll>> fact(ll n) {vector<ll>f(n, 1);RREP(i, 2, n) f[i] = (f[i - 1]*i) % MOD;vector<ll>invf(n, 1);invf[n - 1] = modpow(f[n - 1],MOD-2,MOD);INVREP(i, n - 1, 2) invf[i - 1] = (invf[i]*i) % MOD;return pair<vector<ll>, vector<ll> >(f,invf);}
ll modmult(ll a, ll b, ll M = MOD) { return (a*b) % M; }
ll modadd(ll a, ll b, ll M = MOD) { return (a + b) % M; }
ll comb(pair<vector<ll>, vector<ll>>p, int n, int r) {return modmult(modmult(p.first[n], p.second[r]), p.second[n - r]); }
/*
    auto a = fact(200009);
    cout << comb(a,15,5) << endl;
*/

int main()
{
    /* collection
    int n;
    cin >> n;
    vector<int> A;
    REP(i, n) cin >> A[i];
    vector<pair<int, int>> AB;
    REP(i, n) {cin >> AB[i].first;cin >> AB[i].second;}
    
    sort(ALL(vec),greater<int>());

    map<int, int> mp;
    map<int, int, greater<int>> mp;
    REP(i, 100) mp[i] = i * 10;
    cout << mp.lower_bound(50)->second<<endl;
    cout << mp.upper_bound(50)->second << endl;
    cout << next(mp.upper_bound(50))->second << endl;
    cout << prev(mp.upper_bound(50))->second << endl;
    */
    ll n;
    cin>>n;
    int ans=0;
    RREP(i, 2, (ll)sqrt(n-1)+1){
        ll m=n;
        while(m%i==0)m=m/i;
        if(m%i==1 && m!=n)ans++;
    }
    //if sqrt is integer
    if(fmod(sqrt(n),1.)<0.00000001)ans++;
    
    vector<ll> facts;
    ll m=n-1;
    RREP(i, 2, (ll)sqrt(n-1)+2){
        if(m%i==0){
            m=m/i;
            facts.push_back(1);
            while(m%i==0){
                m=m/i;
                facts.back()++;
            }
        }
    }
    if(m!=1)facts.push_back(1);
    ll tmp=1;
    for(auto i : facts){
        tmp*=i+1;
    }
    cout << ans+tmp<<endl;
}


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

int main() {
	ll t,n,i,j,k,m;
	ll a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0;//, sign = 1;
        // while(check(), notDigits[(int)buf[idx]]){ idx++; }
        // if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        check(), idx++;
        return /*sign **/ ret;
    }
};

int ansSize = 0;
char ans[(int)4e5];
// string ans;
void out(int num){
    if(!num){
        // putchar('0');
        // ans += '0';
        ans[ansSize++] = '0';
        return;
    }
    char buf[16];
    int idx = 0;
    while(num){
        auto ret = div(num, 10);
        buf[idx] = ret.rem + '0';
        num = ret.quot;
        idx++;
    }
    for(int i = idx - 1; i >= 0; i--){
        // putchar(buf[i]);
        // ans += buf[i];
        ans[ansSize++] = buf[i];
    }
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    // for(int i = 1; i <= lim; i++){
    //     accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) >> 1]);
    // }
    for(int i = 1; i <= lim; i += 2){
        accs[i] = prime[i] && prime[(i + 1) >> 1];
    }
    for(int i = 1; i <= lim; i++){
        accs[i] += accs[i - 1];
    }
    // printd(accs[lim]);
    // int q; cin >> q;
    int q = buf.next();
    // stringstream ss;
    // ans.reserve(4 * q);
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        // cout << accs[r] - accs[l - 1] << '\n';
        // ss << accs[r] - accs[l - 1] << '\n';
        out(accs[r] - accs[l - 1]);
        // putchar('\n');
        // ans += '\n';
        ans[ansSize++] = '\n';
    }
    // cout << ss.str();
    // cout << ans;
    // write(1, ans.data(), ans.size());
    write(1, ans, ansSize);
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool is(string s)
{
	for(int i=0;i<s.size()/2;i++)
	{
		if(s[i]!=s[s.size()-i-1])
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	IOS;
	string s,s1,s2;
	cin>>s;
	for(int i=0;i<s.size()/2;i++)
	{
	     	s1.pb(s[i]);
	}
	for(int i=(s.size()+3)/2-1;i<s.size();i++)
	s2.pb(s[i]);
//	cout<<s1<<" "<<s2;
	if(is(s)&&is(s1)&&is(s2))
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	char	str;
  	std::cin >> str;
  
  	if(str == 'A')
    {
    	printf("T");
    }
  	else if(str == 'T')
    {
  		printf("A");
    }
  	else if(str == 'C')
    {
        	printf("G");
    }
  	else
    {
    	    	printf("C");
    }
  
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
tp=[0]*121
for a in A:
    index=0
    while a!=0:
        tp[index]+=a%2
        a//=2
        index+=1
L=[i for i in range(len(tp)) if tp[i] <= N//2][::-1]
x = 0
for i in L:
    if x + 2**i <= K:
        x+=2**i
print(sum([x^i for i in A]))

Measured memory_bytes: 14708
## coding: UTF-8
N = int(input())
lxy = [list(map(int, input().split())) for _ in range(N)]


p_max = (-1) * (10**10)
p_min = (10**10)

m_max = (-1) * (10**10)
m_min = 10**10

for i in range(N):
    l = lxy[i]
    p = l[0] + l[1]
    m = l[0] - l[1]

    if(p_max < p):
        p_max = p
    if(p_min > p):
        p_min = p
    
    if(m_max < m):
        m_max = m 
    if(m_min > m):
        m_min = m

print(max(p_max-p_min, m_max-m_min))










Measured memory_bytes: 106668
#include <iostream>
using namespace std;
int main()
{
	int A,B,C;
	while(cin>>A>>B>>C)
	{
		if(A==5 && B==5 && C==7||A==5 && B==7 && C==5||A==7 && B==5 && C==5)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*input
4
expr
expr
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;

	for(int i=0;i<n;i++){
		bool flag=1;
		for(int j=i;j<n;j++){
			if(s[j]!=t[j-i]) flag=0;
		}

		if(flag){
			cout<<n+i<<'\n';
			return 0;
		}
	}
	cout<<n+n<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int N;
  double ans = 0;
  cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++) cin >> v.at(i);
  sort(v.begin(), v.end());
  
  ans = v.at(0);
  for(int i = 1; i < N; i++){
    ans = (ans+v.at(i))/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
 <url:>
 ?????????============================================================
 ??????????????????JOI?????¨?????§?????????????????????
 JOI?????¨???????????¬??¨???500??????100??????50??????10??????5??????1?????????????????°???????????????
 ????????????????????°????°??????????????????????????????????????????????????????????
 ????????????JOI?????¨?????§????????????????????¬?????§1000?????????1??????????????????
 ???????????????????????????????????¬??¨????????°????±???????????????°????????????????????????
 =================================================================
 ?§£??¬=============================================================
 ????????????
 ================================================================
 */

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    int K[6] = {500,100,50,10,5,1};
    while(cin >> N,N){
        int res = 0;
        N = 1000 - N;
        for(int i = 0; i < 6;i++){
            res += N/K[i];
            N %= K[i];
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
    
    string S;
    cin>>S;
    int n=0,w=0,s=0,e=0;
    rep(i,S.size()){
        if(S[i]=='N')n++;
        else if (S[i]=='W')w++;
        else if (S[i]=='S')s++;
        else if (S[i]=='E')e++;
    }
    if((n>0&&s>0)||(s==0&&n==0)){
        if((w>0&&e>0)||(e==0&&w==0)){
            fin("Yes");
            return 0;
        }
    }
    fin("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int main(){
	while(1){
		int ti[86410];
		REP(i,86410)ti[i]=0;
		cin>>n;
		if(n==0)break;
		REP(i,n){
			string s;
			cin>>s;
			int t=0;
			t+=36000*(s[0]-'0');
			t+=3600*(s[1]-'0');
			t+=600*(s[3]-'0');
			t+=60*(s[4]-'0');
			t+=10*(s[6]-'0');
			t+=(s[7]-'0');
			ti[t]+=1;
			cin>>s;
			t=0;
			t+=36000*(s[0]-'0');
			t+=3600*(s[1]-'0');
			t+=600*(s[3]-'0');
			t+=60*(s[4]-'0');
			t+=10*(s[6]-'0');
			t+=(s[7]-'0');
			ti[t]-=1;
		}
		for(int i=1;i<86410;i++){
			ti[i]=ti[i]+ti[i-1];
		}
		int ans=0;
		REP(i,86410){
			ans=max(ans,ti[i]);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3500
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		int num[10] = {0};
		int j;
		char str[10];
		int max, min;
		
		scanf("%s", str);
		for (j = 0; str[j] != 0; j++){
			num[str[j] - '0']++;
		}
		max = min = 0;
		for (j = 9; j >= 0; j--){
			if (num[j] > 0){
				int k;
				for (k = 0; k < num[j]; k++){
					max *= 10;
					max += j;
				}
			}
		}
		for (j = 0; j < 10; j++){
			if (num[j] > 0){
				int k;
				for (k = 0; k < num[j]; k++){
					min *= 10;
					min += j;
				}
			}
		}
		printf("%d\n", max - min);
	}
	
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner; 

class Main{

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(true){
			int n = scan.nextInt();
			int k = scan.nextInt();

			if(n==0&&k==0){
				break;
			}

			int[] s = new int[k];
			boolean flag=true;

			for(int i=0;i<k;i++){
				s[i]=scan.nextInt();
			}

			int[] adder = new int[k];

			for(int j=0;j<n;j++){
				for(int i=0;i<k;i++){
					adder[i]+=scan.nextInt();
				}
			}

			for(int i=0;i<k;i++){
				if(adder[i]>s[i]){
					flag=false;
				}
			}	
		
			if(flag){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}
		}

	}
}

Measured memory_bytes: 94948
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
string s;
cin >> s;
s[5] = ' ';
s[13] = ' ';
cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int a[100010];
int b[100010];
int c[100010];
long long i,temp,n,q,p;
using namespace std;
long long f(long long e,int a[],long long r,long long l)
{
    while(l>=r)
    {
        temp=r+(l-r)/2;
        if(a[temp]<e)
           r=temp+1;
        if(a[temp]>=e)
             l=temp-1;
    }
    return r;
}
long long F(long long  e,int c[],long long  r,long long l)
{
    while(l>=r)
    {
        temp=r+(l-r)/2;
        if(c[temp]<=e)
           r=temp+1;
        if(c[temp]>e)
             l=temp-1;
    }
    return l+1;
}
int main()
{
    while(~scanf("%lld",&n))
    {
       long long  sum=0;
        for(i=0; i<n; i++)
            scanf("%lld",&a[i]);
        for(i=0; i<n; i++)
            scanf("%lld",&b[i]);
        for(i=0; i<n; i++)
            scanf("%lld",&c[i]);
        sort(a,a+n);
        sort(b,b+n);
        sort(c,c+n);
        for(i=0; i<n; i++)
        {
            long long  e=b[i];
            q=f(e,a,0,n-1);
            p=F(e,c,0,n-1);
            p=n-p;
            sum=sum+q*p;
        }
        printf("%lld\n",sum);
    }
    return 0;
}

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

int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    for(int i=0;i<N;i++) cin >> P.at(i);
    for(int i=0;i<N;i++) cin >> C.at(i);
    for(int i=0;i<N;i++) P.at(i)--;

    long long ans = -1e18;

    for(int si=0;si<N;si++){
        int x = si;
        vector<int> score;
        long long cycle_total = 0;
        while(true){
            x = P.at(x);
            score.push_back(C[x]);
            cycle_total += C[x];
            if(x == si) break;
        }
        int cycle_length = score.size();
        long long now = 0;
        for(int i=0;i<cycle_length;i++){
            if(i+1 > K) break;
            now += score[i];
            long long cycle_val = 0;
            if(cycle_total > 0 ){
                long long e = (K-(i+1))/cycle_length;
                cycle_val = cycle_total * e;
            }
            ans = max(ans, now+cycle_val);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int A ,B, K, L, S;
  cin >> A >> B;
  K = A+B;
  L = K%2;
  S = K/2;
  if (L == 0){
      cout << S;
  }
  else {
      cout << "IMPOSSIBLE";
  }
}

Measured memory_bytes: 256
k,a,b=map(int,input().split())

num=b-a
ans=0

if num <= 2:
  print(1+k)
else:
  ans=(a-1)
  k-=(a-1)
  s=k//2
  l=k%2
  ans=s*num+l+a
  print(ans) 
 

Measured memory_bytes: 9116
N = int(input())
li = list(map(int,input().split()))	
li2 = list(map(int,input().split()))	

ans = 0
res = li[0]
for i in range (N):
        if res > li2[i]:
                ans += li2[i]
                res = li[i+1] 
        else:  
                if li[i+1] >= li2[i] - res:
                        ans += li2[i] 
                        res = li[i+1] - (li2[i] - res)
                else:
                        ans += res + li[i+1]
                        res = 0
print(ans)



Measured memory_bytes: 82020
import timeit

a = [input() for i in range(2)]

S = a[0]
T = a[1]

def count_diff2(S,T):
    cnt = 0
    for c1,c2 in zip(S, T):
        if c1 != c2:
            cnt += 1
    return cnt

print(count_diff2(S,T))


Measured memory_bytes: 9432
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: 井井井 / ###
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = 100000;

typedef long long ll;
const ll MOD = 1000000007;

/* typedef */

/* global variables */

int xs[MAX_N], ys[MAX_M];

/* subroutines */

/* main */

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

  ll xsum = 0, ysum = 0;
  for (int i = 0; i < n; i++) {
    ll pxi = xs[i], mxi = MOD - xs[i];
    while (pxi < 0) pxi += MOD;
    while (mxi < 0) mxi += MOD;
    pxi %= MOD, mxi %= MOD;
    xsum = (xsum + pxi * i % MOD + mxi * (n - 1 - i) % MOD) % MOD;
  }
  for (int i = 0; i < m; i++) {
    ll pyi = ys[i], myi = MOD - ys[i];
    while (pyi < 0) pyi += MOD;
    while (myi < 0) myi += MOD;
    pyi %= MOD, myi %= MOD;
    ysum = (ysum + pyi * i % MOD + myi * (m - 1 - i) % MOD) % MOD;
  }

  //printf("xsum=%lld, ysum=%lld\n", xsum, ysum);
  printf("%lld\n", xsum * ysum % MOD);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,k;
char s[2333],t[2333];
int main()
{
	scanf("%d",&n);
	scanf("%s%s",s+1,t+1);
	for(int i=1;i<=n;i++)
	{
		printf("%c%c",s[i],t[i]);
	}
	return 0;
}

Measured memory_bytes: 256