akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; ++i) {
    string s = to_string(i);
    string t = s;
    reverse(rng(t));
    if (s == t) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    ll n;
    cin>>n;
    ll a[n],b[n+1]={0};
    for(ll i=1;i<n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    for(ll i=1;i<n;i++)
    {
        cout<<b[i]<<endl;
    }
    cout<<0<<endl;

}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)

int main(){
    int s,w;cin>>s>>w;

    if(s<=w)cout<<"unsafe"<<endl;
    if(s>w)cout<<"safe"<<endl;


}

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

int main()
{  
   double a,b;
   cin>>a>>b;
   for(int i=1;i<=1009;i++){ 
       double aa=i*(8/100.0);
       double bb=i*(10/100.0);
       aa=floor(aa);
       bb=floor(bb);
       if(aa==a&&bb==b){ 
           cout<<i;
           return 0;
       }
   }
   cout<<-1;
   

    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,ans=0;
  cin >>n >>m;
  int a[m];
  for(int i=0;i<m;i++){
    cin >> a[i];
    ans+=a[i];
  }
  if(n-ans<0)cout << -1 <<endl;
  else cout << n-ans << endl;
  
}

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

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

    char t;
    if (s[k-1] == 'A') t = 'a';
    else if (s[k-1] == 'B') t = 'b';
    else t = 'c';

    s[k-1] = t;

    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
struct edge { int to, from, cost; };
long long int INF = 1000000000000000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, p;
  cin >> n >> m >> p;

  int a[m], b[m], c[m];
  for(int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }

  edge es[m];
  for(int i = 0; i < m; i++) {
    es[i] = (edge) { b[i], a[i], p - c[i]};
  }
  long long int d[n];
  for(int i = 0; i < n; i++) d[i] = INF;
  d[0] = 0;

  bool neg_loop[n];
  for(int i = 0; i < n; i++) {
    neg_loop[i] = false;
  }
  for(int i = 0; i < 2 * n; i++) {
    for(int j = 0; j < m; j++) {
      edge e = es[j];
      if(d[e.to] > d[e.from] + e.cost && d[e.from] != INF) {
        d[e.to] = d[e.from] + e.cost;
        if(i >= n) {
          neg_loop[e.to] = true;
        }
      }
    }
  }

  long long int d_neg[n];

  //check negative loop
  for(int i = 0; i < n; i++) {
    if(neg_loop[i]) d_neg[i] = 0;
    else d_neg[i] = INF;
  }

  for(int i = 0; i <  n; i++) {
    for(int j = 0; j < m; j++) {
      edge e = es[j];
      if(d_neg[e.to] > d_neg[e.from] + e.cost && d_neg[e.from] != INF) d_neg[e.to] = d_neg[e.from] + e.cost;
    }
  }
  if(d_neg[n - 1] < INF) {
    cout << -1 << "\n";
    return 0;
  }


  if (d[n - 1] > 0) {
    cout << 0 << "\n";
  } else {
    cout << -d[n - 1] << "\n";
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

typedef long long ll;

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

    string s;
    cin >> s;
    for (int i = 0; i < A+B+1; ++i)
    {
        if (i == A)
        {
            if (s[i] != '-')
            {
                puts("No");
                return 0;
            }
        }
        else
        {
            if (s[i] == '-')
            {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define M 8
#define Clear -1
#define GOver 1

void Setup(int);

int Queen[M][M];
int RJud[M];
int CJud[M];
int Lobjud[2*M-1];
int Rdbjud[2*M-1];

int main(){
  int loop;
  int i,j;
  int Ver,Side;

  scanf("%d",&loop);

  for(i=0;i<M;i++){
    
    for(j=0;j<M;j++){
      Queen[i][j]=0;
    }
  }

  for(i=0;i<M;i++){
    RJud[i]=Clear;
    CJud[i]=Clear;
  }

  for(i=0;i<2*M-1;i++){
    Lobjud[i]=Clear;
    Rdbjud[i]=Clear;
  }
  
  for(i=0;i<loop;i++){
    scanf("%d %d",&Ver,&Side);
      Queen[Ver][Side]=1;
  }

  Setup(0);
  
  return 0;
}

void Setup(int Qnum){
  int i,j;
  
  if(Qnum==M){

    for(i=0;i<M;i++){
      for(j=0;j<M;j++){
	if(Queen[i][j]==1){
	  if(RJud[i]!=j){
	    return;
	  }
	}
      }
    }
    
    for(i=0;i<M;i++){
      for(j=0;j<M;j++){
	
	if(RJud[i]==j){
	  printf("Q");
	}
	
	else{
	  printf(".");
	}
      }
      printf("\n");
    }
    
    return;
  }

  else{
    
    for(i=0;i<M;i++){
      if((CJud[i]==GOver) || (Lobjud[i+Qnum]==GOver) || (Rdbjud[Qnum-i+M-1]==GOver)){
	continue;
      }

      else{
	RJud[Qnum]=i;
	CJud[i]=GOver;
	Lobjud[Qnum+i]=GOver;
	Rdbjud[Qnum-i+M-1]=GOver;

	Setup(Qnum+1);

	CJud[i]=Clear;
	Lobjud[i+Qnum]=Clear;
	Rdbjud[Qnum-i+M-1]=Clear;
      }
    }
  }
  
}



Measured memory_bytes: 2088
#pragma GCC optimize("Ofast")
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <math.h>
#include <random>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define double long double
#define Matrix vector<vector<int> >
#define kektor vector
#define pii pair<int, int>
#define pp pair
#define all(x) x.begin(), x.end()
  
using namespace std;
  
typedef long long ll;                                                             
  
int RandInt(int min, int max) {
    if (max < min) {
        swap(min, max);
    }
    random_device rd;
    mt19937 mt(rd());
    uniform_int_distribution<int> dist(min, max);
    return dist(mt);
}

const int maxn = 3e5 + 1, mod = 1e9 + 7, inf = 1e18;
int n;
set<string> el;

void solve() {                          
	cin >> n;
	for (int i = 0; i < n; ++i)  {
		string s;
		cin >> s; 
		el.insert(s);
	}
	if (el.size() == 3) {
		cout << "Three"; 
		return;
	}
	cout << "Four";
}         
  
signed main() {
    cout.precision	(10);
    cout << fixed;
    ios_base::sync_with_stdio(false);
   	cin.tie(0);
    cout.tie(0);
    #ifdef offline
   		freopen("TASK.in", "r", stdin);
    	freopen("TASK.out", "w", stdout);
    #endif
    solve();
    return  0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
    int a,b,t, tb=0, i=1;
    scanf("%d%d%d", &a,&b,&t);
    while(i*a<=t and a<=t){
        tb+=b;
        i++;
        //printf("%d\n", tt);
    }
    printf("%d", tb);
    return 0;
}


Measured memory_bytes: 128
import sys 
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10**9 + 7

def calc_combination(n, k, MOD):
    if k > n - k:
        k = n - k
    ans = 1
    for i in range(1, k + 1):
        ans *= n + 1 - i
        ans *= pow(i, MOD - 2, MOD)
        ans %= MOD
    return ans
 
 
x, y = map(int, input().split())
m = 2 * y - x
n = 2 * x - y
 
if m < 0 or n < 0:
    ans = 0
elif m % 3 != 0 or n % 3 != 0:
    ans = 0
else:
    m //= 3
    n //= 3
    ans = calc_combination(m + n, n, MOD)

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
#define int long long
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

signed main(){
	int n;
	cin>>n;
	int a[n],tmp[n];
	rep(i,n){
		cin>>a[i];
		if(i){
			tmp[i]=tmp[i-1]+a[i];
		}else tmp[i]=a[i];
	}
	int ans=1e12;
	rep(i,n-1){
		ans=min(ans,abs(tmp[i]-(tmp[n-1]-tmp[i])));
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  bool cards[4][14];
  int n, rank;
  char suit;
  
  for ( int s = 0; s < 4; s++ )
    for ( int r = 1; r <= 13; r++ )
      cards[s][r] = 0;
  
  cin >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> suit >> rank;
    if ( suit == 'S' ) cards[0][rank] = 1;
    if ( suit == 'H' ) cards[1][rank] = 1; 
    if ( suit == 'C' ) cards[2][rank] = 1; 
    if ( suit == 'D' ) cards[3][rank] = 1; 
  }
  
  for ( int s = 0; s < 4; s++ ){
    for ( int r = 1; r <= 13; r++ ){
      if ( cards[s][r] ) continue;
      if ( s == 0 ) suit = 'S';
      if ( s == 1 ) suit = 'H';
      if ( s == 2 ) suit = 'C';
      if ( s == 3 ) suit = 'D';
      cout << suit << " " << r << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1160
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		Integer N = Integer.parseInt(sc.next());
		int result=0;
		if(N % 2 ==0) {
			result = N / 2 -1;
		}
		else {
			result = N /2;
		}
		out.println(result);
		out.flush();
	}
}

Measured memory_bytes: 21716
n = int(input())
mx = 100004
array = [1 for _ in range(mx)]
array[0] = array[1] = 0
for i in range(4, mx, 2):
    array[i] = 0
for i in range(3, mx, 2):
    if not array[i]:
        continue
    for j in range(i+i, mx, i):
        array[j] = 0
for i in range(n, mx):
    if array[i]:
        print(i)
        break

Measured memory_bytes: 44784
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int a = sc.nextInt();
        int b = sc.nextInt(),ans=b;
        if(6<=a && a<=12)ans=b/2;
        if(a<6)ans=0;


        out.println(ans);
        out.flush();
    }
    



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}


//class P implements Comparable<P>{
//    long a,b; 
//    int id;
//    P(long a, long b,int id) {
//        this.a=a;
//        this.b=b;
//        this.id=id;
//    }
//    public int compareTo(P p){
//    	if(a*b-p.a*p.b>0) return 1;
//    	if(-a*b+p.a*p.b>0) return -1;    	
//        return 0;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a,s;
    s=0;
    for(int i=0; i<m; i++)
    {
        cin>>a;
        s+=a;
    }
    if(n-s>=0)
        cout<<n-s<<endl;
    else
        cout<<-1<<endl;
}

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

/*==============変数宣言==============*/
int N;
const int M = 26;
int n;
int m = M;
const int def = 1000000;

int c[30];
int s[400][30];

void input(){
	scanf("%d", &N);
	n = N;

	for(int i = 0;i < M;i++) scanf("%d", &c[i]);

	for(int i = 0;i < N;i++)
		for(int j = 0;j < M;j++)
			scanf("%d", &s[i][j]);
	
	return;
}

/*================関数================*/
struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

struct Timer {
  chrono::high_resolution_clock::time_point st;

  Timer() { reset(); }

  void reset() {
    st = chrono::high_resolution_clock::now();
  }

  chrono::milliseconds::rep get() {
    auto ed = chrono::high_resolution_clock::now();
    return chrono::duration_cast< chrono::milliseconds >(ed - st).count();
  }
};

Timer timer;
RandomNumberGenerator rnd;
/*====================================*/



void init(){
	input();
	return;
}


void output(short ans[]){
	for(int i = 0;i < n;i++){
		printf("%d\n", ans[i]+1);
	}
}

int getScore(short a[]){
	int last[30] = {};
	int ans = 0;
	for(int i = 0;i < n;i++){
		ans += s[i][a[i]]; 
		last[a[i]] = i+1;
		for(int j = 0;j < M;j++){
			ans -= c[j] * ((i+1)-last[j]); 
		}
	}
	return ans;
}

int main(){
	init();

	short now[365];
	short ans[365]; 

	for(int i = 0;i < n;i++){
		ans[i] = now[i] = rnd(26); 
	}

	int ans_score = getScore(ans);

	const int fin = 1990;
	const double C = fin*1000.0;

	int now_time = 0;
	//int cnt = 0;
	int AS = ans_score;
	short ANS[365];
	while((now_time = timer.get()) < fin){
		int idx = rnd(365);
		int old = now[idx];
		int nxt = rnd(25);
		if(now[idx] >= nxt) nxt++;
		now[idx] = nxt;
		int now_score = getScore(now);

		double r = rnd(100000)/100000.0;

		double line = (fin-now_time)/C; 

		if(ans_score <= now_score || line > r){
			ans[idx] = nxt;
			ans_score = now_score;
			if(AS < ans_score){
				if(AS < ans_score){
					memcpy(ANS, ans, sizeof(ans));
					AS = ans_score;
				}
				//cerr << AS << endl;
			}
		}else{
			now[idx] = old; 
		}
		//cnt++;
	}

	//cerr << cnt << endl;
	output(ANS);

	return 0;
}

Measured memory_bytes: 3872
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()

typedef unsigned long long ll;

int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main(){ 
int N,K; cin >> N >> K;
vector<int> A(N);
int cnt;
rep(i,N) {
cin >> A[i];
if(A[i] == 1) cnt = i; 
}
int left = cnt;
int right ;
if(cnt % (K - 1)== 0){
 right = N - 1 - cnt;
}
else{
     right = N - 1 - cnt - ((K-1) -(cnt % (K - 1))) ;
}
int ans = (left + (K - 2)) / (K -1);
ans += (right + (K - 2)) / (K -1);
cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#define N 55555
using namespace std;

int main(){
 int n, i, j, a=0, k;
 cin>>n;
 for(i=11; i<N; i+=2){
  k=0;
  for(j=3; j<=sqrt(i);j+=2){
   if(i%j==0){
    k=1;
    break;
   }
  }
   if(k==0&&i%5==1){
    cout<<i<<" ";
    a++;
   }
   if(a==n){
    cout<<endl;
    return 0;
   }
 }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(c,(b/a))<<endl;
  

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

using namespace std;

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

typedef struct edge_ {
    int to;
    ll cost;
} edge;

vector<vector<edge> > G;
vector<ll> dist, par;
ll INF = 999999999999;

void dijkstra(int n, int s) {
    for (int i = 0; i < n; i++)
        dist[i] = INF;
    dist[s] = 0;

    priority_queue<P, vector<P>, greater<P> > pque;
    
    pque.push(P((ll)0, s));

    while (!pque.empty()) {
        P p = pque.top();
        pque.pop();
        int u = p.second;
        ll d = p.first;
        if (d > dist[u])
            continue;
        
        for (int i = 0; i < G[u].size(); i++) {
            edge e = G[u][i];
            int v = e.to;
            ll c = e.cost;
            if (dist[v] <= d + c)
                continue;
            
            dist[v] = d + c;
            pque.push(P(dist[v], v));
            par[v] = u;
        }
    }
}

int main() {
    int n, m;   cin >> n >> m;
    G.resize(n);
    dist.resize(n);
    par.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;   cin >> a >> b;
        a--, b--;
        edge e1 = {b, 1}, e2 = {a, 1};
        G[a].push_back(e1);
        G[b].push_back(e2);
    }

    dijkstra(n, 0);
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++)
        cout << par[i]+1 << endl;
    return 0;
}

Measured memory_bytes: 19508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <string>
#include <math.h>
using namespace std;
typedef complex<double> P;
const double PI = 4*atan(1.0);
 
int main(){
	P p(0, 0), dir(0,1);
	while(1){
		double d,r;
		scanf("%lf,%lf", &d, &r);
		if(d==0) break;
		p += dir*d;
		dir *= P(cos(r*PI/180), -sin(r*PI/180));
	}
	int x=p.real(), y=p.imag();
	cout << x << endl << y << endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  cout << "##";
  for(int i=0; i<W; i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0; i<H; i++){
    string S;
    cin >> S;
    cout << "#" << S << "#" << endl;
  }
  cout << "##";
  for(int i=0; i<W; i++){
    cout << "#";
  }
  cout << endl;  
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()

using namespace std;

int main()
{
	int n = 0, m = 0, a = 0;
	while (cin >> n >> m >> a && n != 0)
	{
		vector<vector<int>> dat(1010, vector<int>(10000, 0));
		int cri = 0;
		rep(i, m)
		{
			int tmp[3] = { 0 };
			cin >> tmp[0] >> tmp[1] >> tmp[2];
			dat[tmp[1]][tmp[0]] = tmp[2];
			dat[tmp[2]][tmp[0]] = tmp[1];
			cri = max(tmp[0], cri);
		}
		rep(i, cri)
		{

			if (dat[a][cri - i] == 0) { continue; }
			else if (dat[a][cri - i] > 0) { a = dat[a][cri - i]; }
		}
		printf("%d\n", a);
	}

	return 0;
}

Measured memory_bytes: 42584
from itertools import accumulate
from collections import defaultdict
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = [0] + list(map(int, input().split()))
accum = list(accumulate(A))
count = defaultdict(int)
ans = 0
for i in range(N+1):
    r = accum[i] % M
    ans += count[r]
    count[r] += 1
print(ans)


Measured memory_bytes: 59928
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    F=LLIN(N)
    P=LLIN(N)
    ans = -inf
    max_bit = 1<<10
    for bit in range(1,max_bit):
        res = 0
        for i,f in enumerate(F):
            cnt = 0
            for j in range(10):
                if (1<<j)&bit and f[j]:
                    cnt += 1
            res += P[i][cnt]
        ans = max(res,ans)
    print(ans)
if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n;
vll s;
vll G;
/******* define variable end *******/
vector<ll> color;
bool dfs(ll v, ll c){
	color[v] = c;
	for(ll i = 0; i < G[v].size(); i++){
		if(color[G[v][i]] == c) return false;
		if(color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
	}
	return true;
}
vll d;
void warshall_floyd(){
	for(ll k = 0; k < n; k++){
		for(ll i = 0; i < n; i++){
			for(ll j = 0; j < n; j++){
				if(i == j){
					d[i][j] = 0;
					d[j][i] = 0;
				}else{
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
}
int solve() {
	cin >> n;
	color.resize(n);
	d.resize(n, vl(n, INF));
	s.resize(n, vl(n));
	G.resize(n);
	REP(i, n){
		string str;
		cin >> str;
		REP(j, n){
			s[i][j] = stol(str.substr(j, 1));
			if(s[i][j]){
				G[i].push_back(j);
				G[j].push_back(i);
				d[i][j] = 1;
				d[j][i] = 1;
			}
		}
	}
	ll ans = 0;
	if(dfs(0, 1)){
		warshall_floyd();
		REP(i, n){
			REP(j, n){
				ans = max(ans, d[i][j]);
			}
		}
		cout << ans + 1 << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 4908
S = input()
max_plus = len(S)-1
s = S[::-1]
#print(S,max_plus)                                                             
num = 2**(max_plus)
sum = 0
#print(num)                                                                    

f = 0
#print(n)                                                                      
while(s):
    f+=1
    max = 1
    n = num
    for i in s:
        t = int(i)

        sum += max*t*n
        max = max*10
        n = n//2
    s = s[1:]
    #print(s)                                                                  
#    print(sum)                                                                
    if(f==1):
        num = num//2


print(sum)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
	public static void main(String[] a) {
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		while (in.hasNext()) {
			list.add(in.nextInt());
		}
		Collections.sort(list);
		Collections.reverse(list);
		for (int i = 0; i < 3; i++) {
			System.out.println(list.get(i));
		}
	}
}

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

int main() {
    string s;
    cin>>s;
    if(s.back() == '3') cout<<"bon";
    else if(s.back() == '0' || s.back() == '1' || s.back() == '6' || s.back() == '8') {
        cout<<"pon";
    }
    else cout<<"hon";
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s;cin>>s;
	int n=s.size();
	int cnt=0;
	rep(i,s.size()){
		if(s[i]!=s[n-i-1]){
			s[i]=s[n-i-1];
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c >= 'A' && c <= 'Z') { System.out.print(Character.toLowerCase(c)); }
			else if(c >= 'a' && c <= 'z') { System.out.print(Character.toUpperCase(c)); }
			else { System.out.print(c); }
		}
		System.out.println("");
		sc.close();
	}
}


Measured memory_bytes: 26816
#include<iostream>
using namespace std;
int main()
{
    char s[4];
    cin >> s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){cout << "Bad" << "\n";}
    else{cout << "Good" << "\n";}
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int>H(N);
	for (int i = 0;i < N;i++) {
		cin >> H[i];
	}
	int count = 0;
	for (int i = 0;i < N;i++) {
		if (H[0] == H[i]) {
			count++;
		}
		else if (H[0] < H[i]) {
			H[0] = H[i];
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
from collections import Counter
N,K = map(int,input().split())
sarr = list(map(int,input().split()))
arr = sorted(sarr)
def xsum(arr,n):
    s = 0
    for i in arr:
        s += n^i
    return s
c = Counter()
for i in arr:
    n = 1
    while n <= K:
        if i%2:
            c[n] += 1
        else:
            c[n] += 0
        n *= 2
        i = i >> 1
ans = 0
p = [1]
while(p[-1]*2 <= K):
    p.append(p[-1]*2)
for i in p[::-1]:
    if c[i] < N - c[i]:
        if ans + i <= K :
            ans += i
print(max(xsum(arr,ans),xsum(arr,K)))

Measured memory_bytes: 70160
from collections import deque

s = input()
q = int(input())

t = deque(s)

reverse = False
for _ in range(q):
   query = input()
   if query[0] == '1':
      reverse = not reverse
   elif query[0] == '2':
      _, f, c = query.split()
      if f == '1':
         if reverse:
            t.append(c)
         else:
            t.appendleft(c)
      elif f == '2':
         if reverse:
            t.appendleft(c)
         else:
            t.append(c)

result = ''.join(t)
if reverse:
   result = result[::-1]
print(result)


Measured memory_bytes: 8820
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
typedef long long ll;
typedef double db;
#define lp1(i, n)  for(int i=0; i<(int)(n); ++i)
#define lp2(i, n)  for(int i=0; i<(int)(n-1); ++i)
#define lp3(j, n)  for(int j=1; j<=(int)(n); ++j)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];
int main(){

 int n,x,count=1,sum=0;
 cin>>n>>x;
 lp1(i,n)
 {
     cin>>arr[i];
     sum+=arr[i];
     if(sum<=x)
        count++;
 }
 cout<<count;

go;
}



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

using namespace std;

typedef long long llint;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  vector<P> xy[n];
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int x, y;
      cin >> x >> y;
      x--;
      xy[i].emplace_back(x, y);
    }
  }
  int ans = 0;
  for (int bit = 0; bit < 1 << n; bit++) {
    vector<int> tid(n, 0);
    for (int i = 0; i < n; i++) {
      if (bit >> i & 1) {
        tid[i] = 1;
      }
    }
    bool ok = true;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (tid[i]) {
        cnt++;
        for (auto &v : xy[i]) {
          int x = v.first;
          int y = v.second;
          if (tid[x] != y) ok = false;
        }
      }
    }
    if (ok) ans = max(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

const int MOD=(int)1e9+7;

int add(int a,int b)
{
    a+=b;
    if(a>=MOD)
    {
        a-=MOD;
    }
    if(a<0)
    {
        a+=MOD;
    }
    return a;
}

int mul(int a,int b)
{
    return a*(long long)b%MOD;
}


typedef long long ll;
typedef long double ld;

const int N=100000+5;

int n;
vector<int>g[N];
int dp[2][N];

bool viz[N];

void calc(int nod)
{
    viz[nod]=1;
    dp[0][nod]=dp[1][nod]=1;
    for(auto &nou:g[nod])
    {
        if(viz[nou]) continue;
        calc(nou);
        dp[1][nod]=mul(dp[1][nod],dp[0][nou]);
        dp[0][nod]=mul(dp[0][nod],add(dp[0][nou],dp[1][nou]));
    }
///    cout<<nod<<" : "<<dp[0][nod]<<" , "<<dp[1][nod]<<"\n";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    calc(1);
    cout<<add(dp[0][1],dp[1][1])<<"\n";
    return 0;
}



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

int main() {
#ifdef HOME
	freopen("abc85c.in", "r", stdin);
	freopen("abc85c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, y, s, m10(0), m5(0), m1(0);

	cin >> n >> y;
	y/= 1000;

	while (y > 0) {
		if (y >= 10) {
			y-= 10;
			m10+= 1;
			continue; }

		if (y >= 5) {
			y-= 5;
			m5+= 1;
			continue; }

		if (y >= 1) {
			y-= 1;
			m1+= 1;
			continue; } }


	s = m10 + m5 + m1;
	if (n >= s)
	for (int i = 0; i <= m10; ++i) if ((n - m10 - m5 - m1 - i) % 4 == 0) {
		if (m5 + 2 * i - (n - s - i) / 4 >= 0) {
			m10-= i;
			m5+= 2 * i - (n - s - i) / 4;  
			m1+= (n - s - i) / 4 * 5;

			cout << m10 << ' ' << m5 << ' ' << m1 << endl;
			return 0; } }

	cout << "-1 -1 -1" << endl;

	return 0; }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,q;
	cin>>n>>q;
	int ans=0;
	int min1=INT_MAX;
	int i;
	int x;
	for(i=0;i<n;i++){
		cin>>x;
		min1=min(x,min1);
		ans+=x;
	}
	q-=ans;
	if(q>=0){
		cout<<n+(q/min1);
		cout<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)

bool judgeTriple(int tmp2[], int count){
  if(count==4)
    return true;
  for(int i=1; i<=7; i++){
    if(tmp2[i]>=1 && tmp2[i+1]>=1 && tmp2[i+2]>=1){
      tmp2[i]--;
      tmp2[i+1]--;
      tmp2[i+2]--;
      if(judgeTriple(tmp2,count+1))
	return true;
      tmp2[i]++;
      tmp2[i+1]++;
      tmp2[i+2]++;
    }
  }
  REP(i,10){
    if(tmp2[i]>=3){
      tmp2[i]-=3;
      if(judgeTriple(tmp2,count+1))
	return true;
      tmp2[i]+=3;
    }
  }
  return false;
}

bool isEnd(int tmp[]){
  REP(i,10){
    if(tmp[i]>=5)
      return false;
  }
  // remove head
  for(int i=1; i<10; i++){
    if(tmp[i]>=2){
      tmp[i]-=2;
      if( judgeTriple(tmp,0) )
	return true;
      tmp[i]+=2;
    }
  }
  return false;
}

int main()
{
  string str;
  while(cin>>str){
    int nums[10];
    memset(nums, 0, sizeof(nums));

    REP(i,str.size())
      nums[str[i]-'0']++;

    vector<int> res;

    for(int i=1; i<=9; i++){
      int tmp[10];
      memcpy(tmp, nums, sizeof(nums));
      tmp[i]++;

      if(isEnd(tmp)){
	res.push_back(i);
      }
    }

    if(res.empty())
      cout << "0" << endl;
    else{
      bool first=true;
      IREP(it,res){
	if(!first)
	  cout << " ";
	first = false;
	cout << *it;
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int x, y;
	cin >> x >> y;
	if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
		if (x > y) cout << 2 + x - y << endl;
		else cout << y - x << endl;
	}
	if ((x > 0 && y < 0) || (x < 0 && y > 0)) {
		cout << abs(y - (-x)) + 1 << endl;
	}
	if (x == 0 || y == 0) {
		if (x > y) cout << x - y + 1 << endl;
		else cout << y - x << endl;
	}
}

Measured memory_bytes: 3608
void main(){
	int[] val = _scanln();
	foreach(elm; val){
		if( count(val, elm)==2 ){
			writeln("Yes");
			return;
		}
	}
	writeln("No");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2716
nums = [int(e) for e in input().split()]

r = nums[0]
d = nums[1]
x = nums[2]

ans = 0

ans = x * r - d
print(ans)

ans = ans * r - d
print(ans)
ans = ans * r - d
print(ans)
ans = ans * r - d
print(ans)
ans = ans * r - d
print(ans)
ans = ans * r - d
print(ans)
ans = ans * r - d
print(ans)
ans = ans * r - d
print(ans)
ans = ans * r - d
print(ans)
ans = ans * r - d
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int i, j, flag1, flag2, flag3, n;
  char s[15], mozi[15];

  scanf("%s", s);
  n = 0;
  for (i = 0; s[i] != 0; i++) {
    mozi[i] = s[i];
    n++;
  }

  flag1 = 0;
  flag2 = 0;
  flag3 = 0;
  for (i = 0; i < n; i++) {
    if (i == 0) {
      if (mozi[i] == 'A') {
        flag1 = 1;
      }
    }
    if (i >= 2 && i <= n-2) {
      if (mozi[i] == 'C') {
        flag2++;
      }
      if (mozi[i] != 'C' && mozi[i] >= 0x41 && mozi[i] <= 0x5a)
      flag3 = 1;
    }
    if (i == 1 || i == n-1) {
      if (mozi[i] >= 0x41 && mozi[i] <= 0x5a){
        flag3 = 1;
      }
    }
  }

  if (flag1 == 1 && flag2 == 1 && flag3 == 0) {
    printf("AC\n");
  }
  else {
    printf("WA\n");
  }

  return 0;
}


Measured memory_bytes: 128
N=int(input())
import collections
l=list(map(int,input().split()))
cnt=collections.Counter(l)
if cnt[0] > 1 or l[0] != 0:
   print(0)
   exit()
ans=1
mod=998244353
for i in range(1,max(cnt)):
   ans*=pow(cnt[i],cnt[i+1],mod)
   ans%=mod
print(ans)

Measured memory_bytes: 19936
#include<iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


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

  int A, B, C; cin>>A>>B>>C;

  if((A<C and C<B) or (B<C and C<A)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
def f(s):
    return (s[0]*60+s[1])*60+s[2]
a=86400
while 1:
    t=[0]*a
    n=int(input())
    if n==0:break
    for _ in range(n):
        b,c = map(lambda x:list(map(int,x.split(':'))),input().split())
        t[f(b)]+=1;t[f(c)]-=1
    d=0
    for i in range(1,a):
        t[i]+=t[i-1]
        if d<t[i]:d=t[i]
    print(d)

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

int main(){
    int A,B;
    cin >> A >> B;
    if(A!=1&&B!=1){
        if(A<B){
            cout << "Bob" << endl;
        }else{
            if(A!=B){
                cout << "Alice" << endl;
            }else{
                cout << "Draw" << endl;
            }
        }
    }else{
        if(A==1){
            if(B!=13){
                if(B!=1){
                    cout << "Bob" << endl;
                }else{
                    cout << "Draw" << endl;
                }
            }else{
                cout << "Alice" << endl;
            }
        }else{
            if(A!=13){
                if(A!=1){
                    cout << "Alice" << endl;
                }else{
                    cout << "Draw" << endl;
                }
            }else{
                cout << "Bob" << endl;
            }
        }
    }
    return 0;
}

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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<long> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    
    vector<int> froml(n), fromr(n);
    froml[0] = fromr[n-1] = 0;
    for(int i = 1; i < n; i++){
        froml[i] = a[i-1] ^ froml[i-1];
        fromr[n-1-i] = a[n-i] ^ fromr[n-i];
    }

    for(int i = 0; i < n; i++){
        if((froml[i]^fromr[i]) != a[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

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

using namespace std;

typedef long long int ll;

const int MAXN = 1e5 + 5;

vector < int > parent(MAXN), sz(MAXN);

void make_set(int u){
  parent[u] = u;
  sz[u] = 1;
}

int find_set(int u){
  if(u == parent[u]) return u;
  return parent[u] = find_set(parent[u]);
}

void union_sets(int u, int v){
  u = find_set(u);
  v = find_set(v);
  if(u != v){
    if(sz[u] > sz[v]) swap(u, v);
    parent[u] = v;
    sz[v] += sz[u];
  }
}

vector < vector < ll > > adj(MAXN, vector < ll > ());

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

  int n, m;
  cin >> n >> m;

  for(int i = 1; i <= n; i++){
    int sz;
    cin >> sz;
    for(int j = 0; j < sz; j++){
      int a;
      cin >> a;
      adj[a].push_back(i);
    }
  }

  for(int i = 1; i <= n; i++) make_set(i);

  for(int i = 1; i <= m; i++){
    for(int j = 1; j < adj[i].size(); j++) union_sets(adj[i][j], adj[i][j - 1]);
  }

  int p = find_set(1);

  if(sz[p] == n) cout << "YES" << '\n';
  else cout << "NO" << '\n';
}


Measured memory_bytes: 5504
#include <stdio.h>
int main(void){
    int X;
    
    scanf("%d",&X);
    
         switch(X%7){
          case 0:
          printf("thu\n");
          break;
          
          case 1:
          printf("fri\n");
          break;
         
          case 2:
          printf("sat\n");
          break;
         
          case 3:
          printf("sun\n");
          break;
         
          case 4:
          printf("mon\n");
          break;
         
          case 5:
          printf("tue\n");
          break;
         
          case 6:
          printf("wed\n");
          break;
         }
    
    return 0;
}


Measured memory_bytes: 2112
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	int d,n,m;
while(
	cin >> d >> n >> m){
	vector<int> v;
	v.push_back(0);
	for(int i=0;i<n-1;i++){
		int a;
		cin >> a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	v.push_back(d);
	int ret=0;
	for(int i=0;i<m;i++){
		int a;
		cin >> a;
		auto it=lower_bound(v.begin(),v.end(),a);
		if(it==v.begin()){
			ret+=a;
		}
		else{
			ret+=min(*it-a,a-*(it-1));
		}
	}
	cout << ret << endl;
}
return 0;
}

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

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 f(int x) {
  int res = 0;
  while (x % 2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  // a -> a'
  rep(i, n) {
    if (a[i] % 2 == 1) {
      cout << 0 << endl;
      return 0;
    }
    a[i] /= 2;
  }

  // a' -> a''
  int t = f(a[0]);
  rep(i, n) {
    if (f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t;  // a[i] /= 2^t
  }
  m >>= t;

  ll l = 1;
  rep(i, n) {
    l = lcm(l, a[i]);
    if (l > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  m /= l;
  int ans = (m + 1) / 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
/***
 **   A S M Atikur Rahman
 **   Update: 26-03-2020
***/

//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<time.h>
#include<limits.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<utility>
#include<iterator>
#include<algorithm>
#include<cassert>
#include<iomanip> ///setprecision


#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sci(x) scanf("%d%*c", &(x))
#define scll(x) scanf("%lld%*c", &(x))
#define scd(x) scanf("%lf%*c", &(x))
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", (x))
#define pfll(x) printf("%lld", (x))
#define pfd(x) printf("%f", (x))
#define pfstr(x) printf("%s", (x))
#define ps printf(" ")
#define pn printf("\n")
#define pfdot printf("..")

#define For(a,n) for(int i=(a); i<(n); i++)
#define rFor(n,a) for(int i=n-1; i>=0; i--)
#define trav(a,x) for (auto& a : x)
#define Mset(ara, val) memset(ara, val, sizeof(ara))

#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define pi  (2*acos(0))


using namespace std;

using ll=long long;
using pii= pair<int,int>;
using pll= pair<long long, long long>;
using pcc= pair<char, char>;
using pdd= pair<double, double>;

#define V(a) vector<a>
using vi= vector<int>;
using vs= vector<string>;
using vll= vector<ll>;
using vpii= vector<pii>;
using vc= vector<char>;
using vd= vector<double>;

//ll POW(ll a,ll b){if(b==0)return 1;ll x=POW(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}
//ll Sqrt(ll a) { ll x=(ll)sqrt(a); if((x+1)*(x+1)==a) x++; return x; }



int main( int argc, char *argv[] )
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stout);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        printf("Yes\n");
    else printf("No\n");




    return 0;
}
























Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,int> pii;
const int N = 1e5+5;
const int M = 1e6+5;
const int Mod = 1e9+7;
#define pi acos(-1)
#define INF 1e8
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
int main()
{
    int a,b;sdd(a,b);
    pr(a*b);
//    system("pause");
    return 0;
}

Measured memory_bytes: 3844