akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define fill(a,val) memset(a,val,sizeof(a))
#define REP(i,a,b) for (auto i = a; i != b; i++)
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define pb push_back
#define SQ(a) (a)*(a)
 
const int N = 100005;
 
using namespace std;


int main()
{
    std::ios::sync_with_stdio(false);

    int T = 1;
    //cin>>T;
    // cin.ignore(); must be there when using getline(cin, s)
    while(T--)
    {
        int n;
        cin>>n;
        map<string,int> m;
        for(int i = 0;i<n;i++)
        {
            string s;
            cin>>s;
            m[s]++;
        }
        cout<<"AC x "<<m["AC"]<<endl;
        cout<<"WA x "<<m["WA"]<<endl;
        cout<<"TLE x "<<m["TLE"]<<endl;
        cout<<"RE x "<<m["RE"]<<endl;
        
        

    }
    return 0;
}



Measured memory_bytes: 3588
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Digits Sum
 */

#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 INF = 1 << 30;

/* typedef */

/* global variables */

/* subroutines */

int digsum(int n) {
  int sum = 0;
  while (n)
    sum += n % 10, n /= 10;
  return sum;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int minsum = INF;
  for (int a = 1; a * 2 <= n; a++) {
    int sum = digsum(a) + digsum(n - a);
    if (minsum > sum) minsum = sum;
  }

  printf("%d\n", minsum);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <unordered_map>
#include <map>

using namespace std;


std::vector<std::vector<int>> graph;
std::vector<bool> used;
std::vector<int> colors;
void Dfs(int v, int col) {
    used[v] = true;
    colors[v] = col;
    for (auto& el : graph[v]) {
        if (!used[el]) {
            Dfs(el, col);
        }
    }
}

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

    int n, k, l;
    cin >> n >> k >> l;
    std::vector<vector<int>> cols;
    auto doing = [&] (int k) mutable {
        graph.resize(n);
        for (int i = 0; i < n; i++) {
            graph[i].clear();
        }
        used.assign(n, 0);
        colors.resize(n);
        for (int i = 0; i < k; i++) {
            int x, y;
            cin >> x >> y;
            x--;
            y--;
            graph[x].push_back(y);
            graph[y].push_back(x);
        }

        int col = 0;
        for (int i = 0; i < n; i++) {
            if (!used[i]) {
                col++;
                Dfs(i, col);
            }
        }
        cols.push_back(colors);
    };
    doing(k);
    doing(l);
    std::map<std::pair<int, int>, int> counts;

    for (int i = 0; i < n; i++) {
        counts[{cols[0][i], cols[1][i]}]++;
    }
    for (int i = 0; i < n; i++) {
        cout << counts[{cols[0][i], cols[1][i]}] << " " ;
    }
    cout << endl;
}


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

using namespace std;

int N;
pair<int, int> task[200004];

bool cmp(pair<int, int> a, pair<int, int> b)
{
	if (a.second < b.second) return true;
	if (a.second == b.second) return a.first > b.first;
	return false;
}

int main()
{
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> task[i].first >> task[i].second;
	}

	sort(task, task + N, cmp);

	int nowTime = 0;

	for (int i = 0; i < N; i++)
	{
		nowTime += task[i].first;
		if (nowTime > task[i].second)
		{
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    int h, w, n;
    cin >> h >> w >> n;
    int i, j;
    vector<int> ct(n);
    vector<vector<int>> mat(h, vector<int> (w));
    for(i = 0; i < n; i++) {
        cin >> ct[i];
    }
    int pos = 0;
    bool lf = true;
    for(i = 0; i < h; i++) {
        if(lf) {
            for(j = 0; j < w; j++) {
                mat[i][j] = pos + 1;
                ct[pos]--;
                if(ct[pos] == 0) {
                    pos++;
                }
            }

        }
        else {
            for(j = w - 1; j >= 0; j--) {
                mat[i][j] = pos + 1;
                ct[pos]--;
                if(ct[pos] == 0) {
                    pos++;
                }
            }
        }
        lf = !lf;

    }
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            cout << mat[i][j] << " ";
        }
        cout << '\n';
    }

    return 0;
}



Measured memory_bytes: 384
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
for i in range(n):
  if n%2==0:
    if i//2*2+1!=b[i]:
      print(0)
      exit()
  if n%2==1:
    if (i+1)//2*2!=b[i]:
      print(0)
      exit()
print(2**(n//2)%(10**9+7))

Measured memory_bytes: 13940
import java.io.*;
import java.util.*;
public class Main
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        int k=sc.nextInt();
        int n=sc.nextInt();
        int m=sc.nextInt();
        boolean found=false;
        for(int x=n;x<=m;x++)
        {
            if(x%k==0)
            {
                found=true;
                break;
            }
        }
        out.println(found?"OK":"NG");
        out.close();
    }
 
    public static void solve()
    {
    }
 
    static class Reader 
    { 
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        public int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        public long nextLong()
        {
            return Long.parseLong(next());
        }
 
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
 
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    } 
}

Measured memory_bytes: 32680
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  ll n,m,a,b,ans=0;cin>>n>>m;
  ll p[n];fill(p,p+n,0);ll h[n];
  for(ll i=0;i<n;i++){
    cin>>h[i];
  }
  for(ll i=0;i<m;i++){
    cin>>a>>b;
    if(h[a-1]<=h[b-1]){p[a-1]=1;}
    if(h[a-1]>=h[b-1]){p[b-1]=1;}
  }
  for(ll i=0;i<n;i++){
    if(p[i]==0){ans++;}
  }
  cout << ans<< endl;
}

Measured memory_bytes: 5156
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    ans=[[1,2,3],[4,5,6],[7,8,9]]
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if b[i]==A[j][k]:
                    ans[j][k]="."
    for i in range(3):
        if len(set(ans[i]))==1:
            print(YES)
            exit()
        if ans[0][i]==ans[1][i]==ans[2][i]:
            print(YES)
            exit()
    if ans[0][0]==ans[1][1]==ans[2][2]:
        print(YES)
        exit()
    if ans[0][2]==ans[1][1]==ans[2][0]:
        print(YES)
        exit()
    print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

N = int(input())
*A, = map(int, input().split())

L = [0]*N
L[0] = A[0]
v = A[0]
for i in range(N-1):
    L[i+1] = v = gcd(v, A[i+1])
R = [0]*N
R[-1] = A[-1]
v = A[-1]
for i in range(N-1, -1, -1):
    R[i] = v = gcd(v, A[i])
ans = max(L[-1], L[-2], R[1])
for i in range(1, N-1):
    ans = max(ans, gcd(L[i-1], R[i+1]))
print(ans)

Measured memory_bytes: 63984
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
 	ll dp[101][100005]={0},i,j,n,cap,wt[1000],val[1000];
 	cin>>n>>cap;
 	for(i=1;i<=n;i++)
 		cin>>wt[i]>>val[i];
 	for(i=1;i<=n;i++)
 	for(j=1;j<=cap;j++)
 	{
 		dp[i][j]=dp[i-1][j];
 		if(j>=wt[i])
 			dp[i][j]=max(dp[i][j],val[i]+dp[i-1][j-wt[i]]);
 	}
 	/*for(i=0;i<=n;i++)
 	{	for(j=0;j<=cap;j++)
 			cout<<dp[i][j]<<" ";
 		cout<<endl;
 	}*/
 	cout<<dp[n][cap]<<endl;
 	
 	     
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{   
    fast;
    int n,k;
    cin>>n>>k;
    vector<int> v;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        v.push_back(t);
    }
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<k;i++)
    {
        sum+=v[i];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
int n, k;
int mapp[10010];
int flag[10010];
int solve(int x)
{
	while(x!=0)
	{
		if(flag[x%10]==1)
			return 0;
		x/=10;
	}
	return 1;
}
int main()
{
	scanf("%d%d", &n, &k);
	for(int i=0; i<k; i++)
    {
        scanf("%d",&mapp[i]);
        flag[mapp[i]] = 1;
    }
    for(int i=n; ;i++)
    {
        if(solve(i))
        {
            printf("%d\n", i);
            return 0;
        }

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  //in
  int n, c, k;
  cin >> n >> c >> k;
  vector<int> t(n);
  REP(i,n) cin >> t[i];
  sort(ALL(t));

  debug(t);

  queue<int> q;
  
  //sort

  //キューを用意．サイズがｃになったらc人pop
  //　または，先頭が滞在可能時間を超えたらmin(c,q.size())人pop
  int cnt = 0;
  REP(i,n){

    if(!q.empty()){
      if(q.front() + k < t[i]){
        int tmp = min(int(q.size()), c);
        debug(tmp);
        REP(ci, tmp) q.pop();
        cnt++;
      }
    }

    q.push(t[i]);

    if(q.size() >= c){
      REP(ci,c) q.pop();
      cnt++;
    }

    debug(int(q.size()));
    debug(cnt);
  }
   debug(int(q.size()));

  if(!q.empty()){
    int tmp = q.size();
    cnt += (tmp+c-1)/c;
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>

using namespace std;
using ll = long long;

struct Block {
    ll w;
    ll s;
    ll v;
};

const int NNODES = 1009;
const int NWEIGHTS = 1e7 + 7;
Block b[NNODES];
ll dp[NWEIGHTS];
ll t[NWEIGHTS];

bool cmp(Block a, Block b) {
    return (a.s + a.w) < (b.s + b.w);
}

ll solve(int n) {
    ll maxV = 0;
    dp[b[0].w] = b[0].v;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= b[i].s+b[i].w; j++) {
            if (j-b[i].w > 0 && dp[j-b[i].w] > 0) {
                t[j] = max(t[j], dp[j-b[i].w] + b[i].v);
                // printf("rrr %d %lld %lld\n", j, b[i].w, dp[j]);
            }
        }
        t[b[i].w] = max(t[b[i].w], b[i].v);
        // printf("rrr %lld %lld\n", b[i].w, dp[b[i].w]);

        for (int j = 1; j <= b[i].s+b[i].w; j++) {
            dp[j] = max(dp[j], t[j]);
            t[j] = 0;
        }
    }
    
    for (int j = 0; j <= NWEIGHTS; j++) {
        maxV = max(maxV, dp[j]);
        // if (dp[j] > 0) {
        //     printf("sss %d %lld\n", j, dp[j]);
        // }
    }
    return maxV;
}
int main() {
    memset(dp, 0, sizeof(dp));
    memset(t, 0, sizeof(t));
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        ll tw, ts, tv;
        cin >> tw >> ts >> tv;
        b[i] = Block{tw, ts, tv};
    }
    sort(b, b+n, cmp);
    // for (int i = 0; i < n; i++) {
    //     printf("%lld %lld %lld\n", b[i].w, b[i].s, b[i].v);
    // }
    printf("%lld\n", solve(n));
    return 0;
}

Measured memory_bytes: 156544
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int>dl(k); for (auto&& x : dl)cin >> x;
	
	int ans = n;
	while (1) {
		bool ok = true;
		string ansS = to_string(ans);
		for (int i = 0; i < ansS.size(); i++) {
			if (count(dl.begin(), dl.end(), ansS[i] - '0') > 0) { ok = false; ans++; break; }			
		}
		if (ok) { cout << ans << endl; return 0; }
	}

	return 0;
}

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

int main(){
    int n;
    cin>>n;
    ll water[n],sum=0;
    for (int i = 0; i < n; ++i) {
        cin >> water[i];
        sum+=water[i];
    }
    sum/=2;
    ll sumt=0;
    for (int k = n+1; k < 2*n; k+=2) {
        sumt+=water[k%n];
    }
    ll now=sum-sumt;
    cout<<2*now<<" ";
    for (int j = 0; j < n-1; ++j) {
        cout<<2*(water[j]-now);
        now=water[j]-now;
        if(j<n-2)cout<<" ";
    }
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 2000003;
const int MOD = 1000000007;

        signed main() {
    cout<<fixed<<setprecision(15);
    int n;
    cin>>n;
    int x[n];
    for(int i=0;i<n;i++)cin>>x[i];
    int ans=0;
    for(int i=0;i<n;i++)ans+=x[i]*x[i];
    int ans2;
    for(int i=1;i<=100;i++){
            ans2=0;
            for(int j=0;j<n;j++)ans2+=(x[j]-i)*(x[j]-i);
            ans=min(ans,ans2);
    }
    cout<<ans;
   

    
      }

        


Measured memory_bytes: 256
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* main */
void Main(void)
{
    vi a;
    a.resize(3);
    for (int rv = 0; rv < 3; rv++)
    {
        cin >> a[rv];
    }
    sort(all(a));
    cout << a[0] << " " << a[1] << " " << a[2] << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

class RMQ
{
	int n;
	vector<int> dat;
public:
	RMQ(int n_)
	{
		n = 1;
		while (n < n_)
		{
			n *= 2;
		}
		dat.resize(2 * n - 1);
		for (int i = 0; i < 2 * n - 1; ++i)
		{
			dat[i] = INT_MAX;
		}
	}
	void update(int k, int a)
	{
		k += n - 1;
		dat[k] = a;
		while (k > 0)
		{
			k = (k - 1) / 2;
			dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	int query(int a, int b, int k = 0, int l = 0, int r = 0)
	{
		if (r <= l)
		{
			r = n;
		}
		if (r <= a || b <= l)
		{
			return(INT_MAX);
		}
		if (a <= l && r <= b)
		{
			return(dat[k]);
		}
		int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return(min(vl, vr));
	}
};

void solve()
{
	int n, q;
	cin >> n >> q;
	RMQ r(n);
	for (int i = 0; i < q; ++i)
	{
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0)
		{
			r.update(x, y);
		}
		else
		{
			cout << r.query(x, y + 1) << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 2060
while values = gets

a,b,c,d,e,f = values.split(' ').map{|i| i.to_f}
if a == 0
 y = (c/b)
 x = ((f-e*y)/d)
elsif b == 0
 x = (c/a)
 y = ((f-d*x)/e)
elsif d == 0
 y = (f/e)
 x = ((c-b*y)/a)
elsif e == 0
 x = (f/d)
 y = ((c-a*x)/b)
else
 x = ((b*f-c*e)/(b*d-a*e))
 y = ((c-a*x)/b)
end
 
if x == 0
  x = x.to_s.delete("-").to_f
end

if y == 0
  y = y.to_s.delete("-").to_f
end

puts "#{sprintf("%.3f",x.round(3))} #{sprintf("%.3f",y.round(3))}"
end

Measured memory_bytes: 8756
import java.util.Scanner;

public class Main {
        static int  cnt =0;
        public static void selectSort(int arr[]) {
            if (arr == null || arr.length < 2){
                return;
            }

            for (int i = 0; i < arr.length; i++){
                int minIdex = i;
                for (int j = i; j < arr.length; j++){
                    minIdex = arr[minIdex] > arr[j] ? j : minIdex;
                }
                swap(arr,i,minIdex);
                if (i != minIdex){
                    cnt++;
                }
            }
        }

        public static void swap(int arr[], int i , int j){
            int tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp;
        }

        public static void printArray(int []arr){
            System.out.print(arr[0]);
            for(int i = 1; i < arr.length; i++) {
                System.out.print(" " + arr[i]);
            }
            System.out.println();
        }

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int N = in.nextInt();
            int[] arr = new int[N];
                    for (int i = 0; i < arr.length; i++) {
                        arr[i] = in.nextInt();
                    }
            selectSort(arr);
                    printArray(arr);
            System.out.println(cnt);
                }

            }




Measured memory_bytes: 26272
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	fmt.Println(solve(N))
}
func solve(N int64) string {
	digits := lib_ToDigitSliceInt64(N)
	if digits[0] == 7 || digits[1] == 7 || digits[2] == 7 {
		return "Yes"
	}
	return "No"
}
func lib_ToDigitSliceInt64(n int64) (digits []int8) {
	nn := int64(n)
	for {
		if nn <= 0 {
			return lib_ReverseInt8(digits)
		}
		digit := int8(nn % 10)
		digits = append(digits, digit)
		nn /= 10
	}
}
func lib_ReverseInt8(values []int8) []int8 {
	newValues := lib_CopyInt8(values)
	for i, j := 0, len(values)-1; i < j; i, j = i+1, j-1 {
		newValues[i], newValues[j] = values[j], values[i]
	}
	return newValues
}
func lib_CopyInt8(values []int8) []int8 {
	dst := make([]int8, len(values))
	copy(dst, values)
	return dst
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> h(N);
  for (ll i = 0; i < N; ++i) {
    cin >> h.at(i);
  }
  vector<ll> dp(N, INF);
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(0) - h.at(1));
  for (ll i = 2; i < N; ++i) {
    dp.at(i) = min(dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)), dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
  }
  cout << dp.at(N - 1) << "\n";
}


Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int k;
  cin>>k;
  vector<long> v(k);
  rep(i,k) cin>>v[i];

  long lb = 2, ub = 2;
  for(int i=k-1; i>=0; i--){
    if( (ub/v[i])*v[i] < lb ){
      cout << -1 << endl;
      return 0;
    }
    lb = ((lb+v[i]-1)/v[i])*v[i];
    ub = (ub/v[i])*v[i] + v[i]-1;
  }

  cout << lb << " " << ub << endl;

  return 0;
}


Measured memory_bytes: 1024
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,K = map(int,input().split())
Max = 2001
#二項係数とその逆元テーブルを作る前処理
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
#O(1)でmod計算した組合せ数を計算
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod

for i in range(1,K+1):
    print(Comb(K-1,i-1)*Comb(N-K+1,i)%mod)

Measured memory_bytes: 4172
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  int m = pow(4, n);
  int ans = 1000000000;
  rep(i, m+1){
    int x = i;
    int la = 0, lb = 0, lc = 0;
    int cost = -30;
    rep(j, n){
      switch(x % 4){
        case 1:
          la += l[j];
          cost += 10;
          break;
        case 2:
          lb += l[j];
          cost += 10;
          break;
        case 3:
          lc += l[j];
          cost += 10;
          break;
      }
      x /= 4;
    }
    if (la == 0 || lb == 0 || lc == 0) continue;
    cost += abs(a-la) + abs(b-lb) + abs(c-lc);
    ans = min(ans, cost);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,x,t,ans;
  cin>>n>>x>>t;
  if(n%x==0){
    ans=n/x*t;
  }else{
    ans=n/x;
    ans++;
    ans=ans*t;
  }
  cout<<ans;
}

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

using namespace std;
using ll = long long;

int main() {
	int N, H, W;
	cin >> N >> H >> W;
	int res = 0;
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		if ((H <= a) && (W <= b)) { ++res; }
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;




//D
public class Main {

    static int N;
    static int Q;
    static IntList[] v;
    static int[] ans;
    static int[] parent;
    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);

        N=sc.nextInt();
        Q=sc.nextInt();
        v=new IntList[N+1];
        ans=new int[N+1];
        parent=new int[N+1];
        for(int i=1;i<=N;i++) {
            v[i]=new IntList(8);
        }
        for(int i=1;i<=N-1;i++) {
            int a=sc.nextInt();
            int b=sc.nextInt();
            v[a].add(b);
            parent[b]=a;

        }

        for(int i=0;i<Q;i++) {
            int p=sc.nextInt();
            int q=sc.nextInt();
            ans[p]+=q;
        }


        for(int i=2;i<=N;i++) {

            int pi=parent[i];
            // System.err.println("i pi "+i+" "+pi);

            if(pi!=0) {ans[i]+=ans[pi];}

        }

        for(int i=1;i<=N;i++) {
            System.out.print(ans[i]+" ");
        }
        System.out.println();
    }
}

class IntList{
    private int[] array;
    private int size = 0;
    public IntList() {
        array = new int[256];
    }

    public IntList(int size) {
        array = new int[size];
    }

    public void add(int a) {
        if(size == array.length) {
            int newSize = Math.min(Integer.MAX_VALUE, size*2);
            array = Arrays.copyOf(array, newSize);
        }
        array[size++] = a;
    }

    public void addAll(IntList list) {
        for (int i = 0; i < list.size(); i++) {
            this.add(list.get(i));
        }
        // TODO convert to copyOf
//        int[] a = list.getArray();
//        int numNew = a.length;
//        if(size + numNew > array.length) {
//            int length = array.length;
//            while (size + numNew < length) {
//                length *= 2;
//            }
//            array = Arrays.copyOf(array, length);
//        }
//        System.arraycopy(a, 0, array, size, numNew);
//        size += numNew;
    }

    public int get(int i) {
        if(i >= size) {
            throw new ArrayIndexOutOfBoundsException(String.format("size=%d, i=%d", i, size));
        }
        return array[i];
    }

    public int size(){
        return size;
    }

    public int[] getArray() {
        return array;
    }
}

Measured memory_bytes: 185460
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	n := iScan()
	p, q := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		x, y := iScan(), iScan()
		p[i] = x + y
		q[i] = x - y
	}
	fmt.Println(larger(max(p)-min(p), max(q)-min(q)))
}


Measured memory_bytes: 8284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)

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

    int r = 0, w = 0;
    rep(i, 0, n) {
        if (s[i] == 'R') r++;
        if (s[i] == 'W') w++;
    }
    int ans = min(r, w);
    int cnt = 0;
    rep(i, 0, r) {
        if (s[i] == 'W') cnt++;
    }
    cout << min(ans, cnt) << endl;
    return 0;
}


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

int main() {
  int N, a = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    a += r - l + 1;
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
require 'prime'
like_2017s = Prime.each(100000).select {|n| Prime.prime?((n+1)/2) }

Q = gets.to_i
Q.times do
    l,r=gets.chomp.split(" ").map(&:to_i)
    l_index = like_2017s.bsearch_index { |x| x >= l }
    if l_index == nil
        puts 0
        next
    end
    r_index = like_2017s.bsearch_index { |x| x > r }
    if r_index == nil
        r_index = like_2017s.length
    end
    puts r_index - l_index
end

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

typedef signed long long ll;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if((a == b) && (a == 0))
        cout << "1\n";
    else {
        ll ans = b / c; 
        ans -= (a == 0) ? -1 : (a - 1) / c;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 305

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

int A[SIZE][SIZE];
bool use[SIZE];
int cnt[SIZE];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			scanf("%d",&A[i][j]);
			A[i][j]--;
		}
	}
	int ret=n;
	for(int i=0;i<m-1;i++)
	{
		memset(cnt,0,sizeof(cnt));
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<m;k++)
			{
				if(!use[A[j][k]])
				{
					cnt[A[j][k]]++;
					break;
				}
			}
		}
		P mx=P(-1,-1);
		for(int j=0;j<m;j++) mx=max(mx,P(cnt[j],j));
		ret=min(ret,mx.first);
		use[mx.second]=true;
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    A, B, C = map(int, input().split())
    K = int(input())

    for _ in range(K):
        if not A < B:
            B *= 2
        elif not B < C:
            C *= 2
    if A < B < C:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9076
s = list(map(str, input()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


ans = 0

for i in range(2**(len(s)-1)):
	if i == 0:
		ans += int("".join(s))
		continue

	b = Base_10_to_n(i,2).rjust(len(s)-1, "0")
	ind = [j for j in range(len(b)) if b[j] == "1"]

	temp = []

	if len(ind) == 1:
		temp.append("".join(s[:ind[0]+1]))
		temp.append("".join(s[ind[0]+1:]))
		ans += sum(list(map(int, temp)))
		continue

	if len(ind) >= 2:
		for k in range(len(ind)):
			if k == 0:
				temp.append("".join(s[:ind[k]+1]))
			if 0 < k <= len(ind)-1:
				temp.append("".join(s[ind[k-1]+1:ind[k]+1]))
			if k == len(ind)-1:
				temp.append("".join(s[ind[k]+1:]))

		ans += sum(list(map(int, temp)))
		continue

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n;
        cin >> n;
        int w=1;
        int i,a[n+1];
        for(i=1; i<=n; i++){
            cin >> a[i];
            if(a[i]%2==0){
                if(a[i]%3==0 || a[i]%5==0){

                }
                else{
                    w=0;
                }
            }
        }
        if(w)cout << "APPROVED" << '\n';
        else cout << "DENIED" << '\n';
        

}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
using namespace std;
int main(){
  int n, s = 0; scanf("%d", &n);
  vector<int> v(n), u(n), a(n+1, 0), b(n+1, 0);
  for(int i = 0; i < n; ++i) scanf("%d", &v[i]);
  for(int i = 0; i < n; ++i) scanf("%d", &u[i]);
  for(int i = 0; i < n; ++i){
    a[i+1] = a[i]+v[i]; b[i+1] = b[i]+u[i];
  }
  for(int i = 0; i < n; ++i) s = max(s, a[i+1]+b[n]-b[i]);
  printf("%d\n", s);
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!
    val b = readLine()!!
    val c = readLine()!!
    var count = 0
    for(i in 0 until n){
        if(a[i] == b[i] && b[i] == c[i]) continue
        if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
            count++
            continue
        }
        count += 2
    }

    println("$count")
}

Measured memory_bytes: 33676
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
const int maxn=100010;
vector<int> adj[maxn];
int dp[maxn];
int st[maxn];
int res;
void dfs(int i,int fa){
	int curst=0;
	int mn=0;
	for (int j=adj[i].size()-1;~j;--j){
		int nxt=adj[i][j];
		if (nxt==fa) continue;
		dfs(nxt,i);
		int nxst=st[nxt];
		mn|=(curst&nxst);
		curst|=nxst;
	}
	for (int j=0;j<=20;++j){
		if (!mn&&!(curst&(1<<j))){
			dp[i]=j;
			st[i]=curst&(~((1<<j)-1));
			st[i]|=(1<<j);
			break;
		}
		if (mn&(1<<j)) mn^=(1<<j);
	}
	if (res<dp[i]) res=dp[i];
}
int main(void){
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;++i){
		int u,v;
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1,-1);
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n;
    cin >> n;
    vector <tuple <string , int ,int> > sp(0);
    rep(i,n){
        string s;
        int p;
        cin >> s >> p;
        tuple <string , int , int> spi (s,-p,i+1);
        sp.push_back(spi);
    }
    sort(all(sp));
    rep(i,n){
        cout << (get <2> (sp[i]))<< endl;
    }
}


Measured memory_bytes: 3624
import math
s = input().split()
n=int(s[0])
k=int(s[1])
result=0
if n>1:
    result+=math.factorial(n)/math.factorial(2)/math.factorial(n-2)
if k>1:
    result+=math.factorial(k)/math.factorial(2)/math.factorial(k-2)
print(int(result))

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

typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i,n)cin >> d[i];
	sort(d.begin(),d.end(),greater<int>());

	int size=1e9;
	int ans = 0;
	for(int i=0; i<n; i++){
		if(d[i]<size){
			ans++; size=d[i];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;

namespace _175_B
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var c = int.Parse(Console.ReadLine());
            var n = Console.ReadLine().Split().Select(int.Parse).ToList();
            if (c < 3)
            {
                Console.WriteLine("0");
                return;
            }

            var count = 0;
            for (var i = 0; i < c - 2; i++)
            {
                for (var j = i + 1; j < c - 1; j++)
                {
                    for (var k = j + 1; k < c; k++)
                    {
                        if (IsTryangle(n[i], n[j], n[k])) count++;
                    }
                }
            }
            Console.WriteLine(count.ToString());
        }

        private static bool IsTryangle(int li, int lj, int lk)
        {
            return li != lj && lj != lk && lk != li
                && li + lj > lk && lj + lk > li && lk + li > lj;
        }
    }
}

Measured memory_bytes: 18912
#include <cstdio>

int main(){
	int n;
	while(scanf("%d",&n),n){
		bool x[100][100];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++) x[i][j] = false;
		}
		for(int i = 0; i < n; i++){
			int m;
			scanf("%d", &m);
			for(int j = 0; j < m; j++){
				int p;
				scanf("%d", &p);
				p--;
				x[i][p] = true;
			}
		}
		int k;
		int l[100];
		scanf("%d", &k);
		for(int i = 0; i < k; i++){
			scanf("%d", &l[i]);
			l[i]--;
		}
		int cnt = 0;
		int ans = 0;
		for(int i = 0; i < n; i++){
			bool ok = true;
			for(int j = 0; j < k; j++){
				if(!x[i][l[j]]){
					ok = false;
					break;
				}
			}
			if(ok){
				ans = i+1;
				cnt++;
			}
		}
		if(cnt != 1) printf("-1\n");
		else printf("%d\n", ans);
	}
}

Measured memory_bytes: 1052
NN = int(input())
A = list(map(int,input().split()))
money = 1000
n_of_kabu = 0
purchased_price = 0
for i in range(NN-1):
    if A[i+1] > A[i]:
        n_of_kabu = int(money/A[i])
        money = money + (A[i+1]-A[i]) * n_of_kabu
print(money)

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

int	main(void)
{
	int n, k;
	cin >> n >> k;
	vector<bool> sunuke(n, false);
	for (int i = 0; i < k; i++)
	{
		int d;
		cin >> d;
		int candy;
		for (int j = 0; j < d; j++)
		{
			cin >> candy; candy--;
			sunuke[candy] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) ans += (1 - sunuke[i]);
	cout << ans << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second

int main(){
    int n;
    while(cin>>n,n){
        vi t(24*60*60+1,0);
        string s,g;
        rep(i,n){
            cin>>s>>g;
            t[stoi(s.substr(0,2))*60*60 + stoi(s.substr(3,2))*60 + stoi(s.substr(6,2))]++;
            t[stoi(g.substr(0,2))*60*60 + stoi(g.substr(3,2))*60 + stoi(g.substr(6,2))]--;
        }
        partial_sum(all(t),t.begin());
        cout<<*max_element(all(t))<<endl;
    }
}

Measured memory_bytes: 3424
object Main extends App {
  val _ = io.StdIn.readInt()
  val arr: Array[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
  val min = arr.min

  def mkGroup(s: IndexedSeq[Int]): Seq[Seq[Int]] = {
    val sorted: Seq[Int] = s.sorted
    val m: collection.mutable.Map[Int, Int] = collection.mutable.Map.empty
    s.indices.foreach(i => m.update(i, sorted.indexOf(s(i))))
    def getCycle(n: Int): List[Int] = m.get(n) match {
      case None => List()
      case Some(x) => m.remove(n); n :: getCycle(x)
    }
    s.indices.map(i => getCycle(i)).filterNot(_.isEmpty)
  }

  def cost(inds: Seq[Int]): Int = {
    val s = inds.map(arr(_))
    val sum = s.sum
    val smin = s.min
    ((s.length - 2) * smin + sum) min ((s.length+1) * min + smin + sum)
  }

  val groups = mkGroup(arr)
  println((groups map cost).sum)
}

Measured memory_bytes: 53268
#!/usr/bin/env python
# coding: utf-8


def main():
    n, m = list(map(int, input().split()))
    ans = [0 for _ in range(m+1)]
    for _ in range(n):
        for a in list(map(int, input().split()))[1:]:
            ans[a] += 1
    print(sum(1 for x in ans if x == n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
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;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int C = 61;
int d[202020][C+1],p[202020];
int n,k;

int getkth(int k, int cur){
  for(int j=0;j<C;j++){
    if(k&(1LL<<j)){
      cur=d[cur][j];
    }
  }
  return cur;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

    cin >> n >> k;
    for(int i=0;i<n;i++){
      cin >> p[i];
      p[i]--;
    }

    for(int i=0;i<n;i++){
       d[i][0]=p[i];
    }

    for(int j=1;j<C;j++){
       for(int i=0;i<n;i++){
          d[i][j]=d[d[i][j-1]][j-1];
       }
    }  

    cout << getkth(k,0) +1 << endl;


return 0;
}
///....


Measured memory_bytes: 102104
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//~ using namespace __gnu_pbds; 
#define mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=2e4+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

//~ typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

struct block{
	int w,s,val;
	void read(){
		cin>>w>>s>>val;
	}
	bool operator<(const block& b) const{
		return w+s<b.w+b.s;
	}
};

//~ ll dp[N];

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n;
	cin>>n;
	vector<block> b(n);
	int max_block=0;
	for(int i=0;i<n;++i){
		b[i].read();
		max_block=max(max_block,b[i].s+b[i].w);
	}
	sort(b.begin(),b.end());
	vector<ll> dp(max_block+1);
	ll ans=0;
	// dp[i] is the best of boxes with total weight i
	for(int i=0;i<n;++i){
		for(int j=b[i].s;j>=0;--j){
			dp[j+b[i].w]=max(dp[j+b[i].w],dp[j]+b[i].val);
			//~ cout<<ans<<endl;
			ans=max(ans,dp[j+b[i].w]);
		}
	}
	cout<<ans;
	return 0;	
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int r,g,b; cin>>r>>g>>b;
    if((g*10+b)%4==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using std::cin;using std::cout;
const int mod=1e9+7;
int n,a,b;

inline ll power(ll x,ll p){
	ll ans = 1;
	while(p){
		if(p & 1) ans = ans * x % mod;
		x = x * x % mod;
		p >>= 1;
	}
	return ans;
}
inline ll C(ll n,ll b){
	ll tt = 1;
	for(int i = 1;i <= b;++i){
		tt = tt * (n-i+1)%mod*power(i,mod-2)%mod;
	}
	return tt;
}
int main(){
	std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> a >> b;
	ll ans = power(2,n) - C(n,a) - C(n,b) - 1;
	cout << (ans % mod + mod) % mod << "\n";
	return 0;
}

Measured memory_bytes: 256
import math

n = int(input())
coods = list(map(int, input().split()))

low_center = math.ceil(sum(coods)/n)
hi_center = sum(coods)//n

ans = 0

if low_center == hi_center:
    for c in coods:
        ans += (c-low_center)**2
else:
    aa = 0
    ab = 0
    for c in coods:
        aa += (c-low_center)**2
        ab += (c-hi_center)**2
    ans = min(aa, ab)
print(ans)

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

int main(int argc, char const *argv[])
{
    string x;
    vector<string> vx;
    string tmp;

    while (true)
    {
        cin >> x;
        if (x == "0")
        {
            break;
        }
        else
        {
            vx.emplace_back(x);
        }
    }

    for (int i = 0; i < vx.size(); i++)
    {
        int sum = 0;
        for (int j = 0; j < vx[i].size(); j++)
        {
            tmp = vx[i][j];
            sum += stoi(tmp);
        }
        cout << sum << endl;
    }

    return 0;
}



Measured memory_bytes: 3180