akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

struct node{
	int pos;
	int prev;
	double cost;

	node(int t_pos,int t_prev,double t_cost){
		pos = t_pos; prev = t_prev; cost = t_cost;
	}

	bool operator<(const node& a) const { //キューの中身を逆転
		return cost > a.cost;
	}
};

struct root{
	int to;
	double cost;

	root(int t_to,double t_cost){
		to = t_to; cost = t_cost;
	}

};

vector< vector <root> > roots;
int n,m,s,g;

double dp[101][101];

const double INF = 9e9;

void search(){

	fill_n((double *)dp,sizeof(dp)/sizeof(double),INF); //初期化	
	
	priority_queue<node> pq;

	rep(i,roots[s].size()){
	
		root r = roots[s][i];
		
		pq.push( node(r.to,s,r.cost) );
		dp[r.to][s] = r.cost;
	}

	while(!pq.empty()){

		node tn = pq.top();
		pq.pop();

		if( dp[tn.pos][tn.prev] != tn.cost) continue;

		if( tn.pos == g){
			cout << g << " " <<tn.cost << endl;
			return;
		}	

		rep(i,roots[tn.pos].size()){
			root r = roots[tn.pos][i];
			if(r.to == tn.prev) continue;

			for( int j = -1; j< 2; j++){
		//		if( tn.speed + j > 0 && tn.speed +j <= r.speed){
					double cost = tn.cost + r.cost;///(tn.speed+j);
					if( dp[r.to][tn.pos] > cost){
						dp[r.to][tn.pos] = cost;
						pq.push( node( r.to,tn.pos,cost));
					}
				//}
			}
		}
	}

	cout << "unreachable" << endl;
}


int main(){

		cin >> n;

		roots = vector< vector<root> >(n);

    rep(i,n){
      int num,m;
      cin >> num >> m;
      roots[num].push_back( root(num,0));
      rep(j,m){
        int r,cost;
        cin >> r>> cost;
        roots[num].push_back( root(r,cost));
      }
    }
    s=0;
    rep(i,n){
		  g=i;
      search();
    }
}

Measured memory_bytes: 1588
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  ll a, b, x;
  ci(a, b, x);
  if(a == 0){
    co(b / x + 1);
  }
  else{
    co(b / x - (a - 1) / x);
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>

#include<chrono>
#include<initializer_list>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

int main() {
	long long N,K;
	cin>>N>>K;
	long long ans=K;
	for(int i=1;i<N;++i)
		ans*=K-1;
	
	cout<<ans<<endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

U = 10**6
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def perm(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[n-k]
    z %= MOD
    return z

def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z *= fact_inv[n-k]
    z %= MOD
    return z

n, m = map(int, input().split())
ans = 0
for i in range(n+1):
  temp = (-1)**i * comb(n, i)
  temp *= perm(m, i)
  temp %= MOD
  temp *= perm(m-i, n-i)**2
  temp %= MOD
  ans += temp
  ans %= MOD
print(ans)

Measured memory_bytes: 97820
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long num = -3000l;
    long b[] = new long[6000];
    long bb[] = new long[6000];
    long a[] = new long[6000];
    long aa[] = new long[6000];
    for(int i = 0;i<6000;i++){
      long gojo = num * num * num * num * num;
      b[i] = gojo;
      bb[i] = num;
      a[i] = gojo;
      aa[i] = num;
      num++;
    }
    for(int i = 0;i<6000;i++){
      for(int j = 0;j<6000;j++){
        if(a[j] - b[i] == x){
          System.out.println(aa[j] + " " + bb[i]);
          return;
        }
      }
    }
  }
}


Measured memory_bytes: 39308
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
using namespace std;

int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	h=h*5.00 +(m/60)*5;
	double p=min(abs(h-m),60-(abs(h-m)));
	double pi=3.14159265358979323846;
	p=(p/60)*pi*2.0;
	
	double ans=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(p));
	printf("%0.10lf",ans);

	
	
			
}



Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n;
struct node{
	string s;
	int x;
}a[N];
int t;
string s[N];
map<string,int> c;
bool cmp(node x,node y){
	return x.s<y.s;
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>s[i];
		c[s[i]]++;	
	}
	int ma=0;
	for(int i=1;i<=n;i++){
		if(c[s[i]]){
			a[t].x=c[s[i]];
			a[t].s=s[i];
			ma=max(ma,c[s[i]]);
			c[s[i]]=0;t++;
		}
	}
	sort(a,a+t,cmp);
	for(int i=0;i<t;i++){
		if(a[i].x==ma)
		 cout<<a[i].s<<endl;
	}
	return 0;
}





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

int main(){

    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<vector<int> > a(n, vector<int> (n));
        vector<vector<pair<int, int> > > hand(n, vector<pair<int, int> > (n, {0, 0}));
        for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a[i][j];

        for(int i = 0; i < n; i++){
            int tmp_m = 100100100;
            for(int j = 0; j < n; j++){
                if(tmp_m > a[i][j]){
                    tmp_m = a[i][j];
                }
            }

            for(int j = 0; j < n; j++){
                if(tmp_m == a[i][j]){
                    hand[i][j].first = true;
                }
            }
            //hand[i][tmp_j].first = true;

        }

        for(int j = 0; j < n; j++){
            int tmp_M = 0;
            int tmp_i;
            for(int i = 0; i < n; i++){
                if(tmp_M < a[i][j]){
                    tmp_M = a[i][j];
                    //tmp_i = i;
                }
            }

            for(int i = 0; i < n; i++){
                if(tmp_M == a[i][j]){
                    hand[i][j].second = true;
                    
                }
            }

            //hand[tmp_i][j].second = true;
        }

        int ans = 0;
        
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(hand[i][j].first && hand[i][j].second) ans = max(ans, a[i][j]);
            }
        }

        cout << ans << endl;

    }

    return 0;
}


Measured memory_bytes: 2996
def examA():
    S = SI()
    ans = 700
    for s in S:
        if s=="o":
            ans +=100
    print(ans)



import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,tmp,s=0,a=1000000000;
  cin>>n;
  tmp=n;
  while(a!=0){
    s+=tmp/a;
    tmp%=a;
    a/=10;
  }
  s+=tmp;
  if(n%s==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 3000000
using namespace std;
struct P
{
  int color,w;
  P(int color=-inf,int w=-inf):color(color),w(w){}
};
P par[MAX];
void init(){ rep(i,MAX)par[i] = P(i); }

P find(int x)
{
  if(x == par[x].color)return par[x];
  P p = find(par[x].color);
  if(par[x].w == -inf)par[x].w = 0;
  par[x].w += p.w,par[x].color = p.color;
  return par[x];
}

void unit(int x,int y,int w)//x <= y
{
  P X = find(x); 
  P Y = find(y);
  par[X.color].color = par[Y.color].color;
  if(par[X.color].w == -inf)par[X.color].w = 0;
  if(par[Y.color].w == -inf)par[Y.color].w = 0;
  par[X.color].w = par[X.color].w + (par[y].w-w - par[x].w);
}

int N,M;

int main()
{
  while(cin >> N >> M,N|M)
    {
      init();
      char c;
      int a,b,w;
      rep(_,M)
	{
	  cin >> c;
	  if(c == '!')
	    {
	      cin >> a >> b >> w;
	      unit(a,b,w);
	    }
	  else
	    {
	      cin >> a >> b;
	      P B = find(b);
	      P A = find(a);
	      if(B.color != A.color)cout << "UNKNOWN" << endl;
	      else cout << B.w-A.w << endl;
	    }
	}
    }
  return 0;
} 

Measured memory_bytes: 25640
#include<cstdio>
#include<array>
using uint = unsigned int;

void scan(uint&d) {
	d = 0;
	int c;
	while (c = fgetc(stdin), c == ' ' || c == '\n');
	do
		d = d * 10 + c - '0';
	while (c = fgetc(stdin), c != ' '&&c != '\n');
}
uint read() {
	uint d;
	scan(d);
	return d;
}

constexpr uint N = 502;

::std::array<::std::array<uint, N>, N> sum;

int main() {
	uint n, m, q;
	scan(n);
	scan(m);
	scan(q);
	uint l, r;
	while (m--) {
		scan(l);
		scan(r);
		++sum[1][r];
		--sum[l + 1][r];
	}

	for (uint i = 1;i < N;++i) {
		for (uint j = 1;j < N;++j) {
			sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
		}
	}

	while (q--) {
		scan(l);
		scan(r);
		printf("%u\n", sum[l][r]);
	}
	return 0;
}


Measured memory_bytes: 1792
n,c,k = map(int,input().split())
times = sorted([int(input()) for _ in range(n)])

ans = 0
bus = []

for t in times:
    if len(bus) in (0,c) or bus[0] + k < t:
        bus = []
        ans += 1
    bus.append(t)

print(ans)

Measured memory_bytes: 8280
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long int li;

struct graph{
  int order;
  int comp;
  vector<vector<int>> adj;
  vector<int> depth;
  vector<int> outcome;
  vector<int> par;

  graph(int n,int m,int origin=1);
  int dfs_tree(int u);
};


int main(){
  if(df) printf("*debug mode*\n");
  int n,u,v; cin >>n >>u >>v; u--; v--;
  graph g(n,n-1);
  g.dfs_tree(v);
  int lim=g.depth.at(u);
  lim=(lim-1)/2;
  rep(i,lim){
    u=g.par.at(u);
  }
  printf("%d",g.outcome.at(u));
}

graph::graph(int n,int m,int origin){
  order=comp=n;
  adj.resize(n);
  par.resize(n,-1);
  depth.resize(n);
  outcome.resize(n);
  rep(i,m){
    int u,v;cin >>u >>v; u-=origin; v-=origin;
    adj.at(u).push_back(v);
    adj.at(v).push_back(u);
  }
}

int graph::dfs_tree(int u){
  static int dep=0;

  depth.at(u)=dep;
  int m=dep-1;
  dep++;
  for(auto v:adj.at(u)){
    if(v==par.at(u)) continue;
    par.at(v)=u;
    int temp=dfs_tree(v);
    if(temp>m)m=temp;
  }
  dep--;
  outcome.at(u)=m;
  return m;
}
/// confirm df==0 ///


Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vector<string> a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll cnt=0;
  sort(a.begin(),a.end());
  rep(i,n-1){
    if(a[i]==a[i+1]){
      cnt++;
    }
  }
  cout << n-cnt << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main(){
    int N; cin >> N;
    int A1[N];
    int A2[N];
    for (int i=0;i<N;i++) cin >> A1[i];
    for (int i=0;i<N;i++) cin >> A2[i];
    int ans = 1;
    for (int i=0;i<N;i++){
        int tmp=0;
        for (int j=0;j<=i;j++) tmp += A1[j];
        for (int j=i;j<N;j++) tmp += A2[j];
        ans = max(ans, tmp); 
    }
    cout << ans << endl;   
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var a = ReadLineStringSplit();
            var result = ">";

            if((a[0] == "A" && a[1] == "B") || (a[0] == "A" && a[1] == "C") || (a[0] == "A" && a[1] == "D") || (a[0] == "A" && a[1] == "E") || (a[0] == "A" && a[1] == "F") ||
               (a[0] == "B" && a[1] == "C") || (a[0] == "B" && a[1] == "D") || (a[0] == "B" && a[1] == "E") || (a[0] == "B" && a[1] == "F") ||
               (a[0] == "C" && a[1] == "D") || (a[0] == "C" && a[1] == "E") || (a[0] == "C" && a[1] == "F") ||
               (a[0] == "D" && a[1] == "E") || (a[0] == "D" && a[1] == "F") ||
               (a[0] == "E" && a[1] == "F")) {

                result = "<";
            }else if(a[0] == a[1]) {
                result = "=";
            }

            Console.WriteLine(result);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

int main(void)
{
	int H,R;
	scanf("%d %d",&H,&R);
	if(H+R==0)printf("%d\n",0);
	else if(H+R>0)printf("%d\n",1);
	else if(H+R<0)printf("%d\n",-1);
	return 0;
}


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

#define mod 1000000007

int main(void){
    int n,k;
    long int sum = 0;
    cin >> n >> k;
    if(k == 10)cout << (to_string(n).size());
    else {
        for(int i = 1;n > 0;i++){
            n /= k;
            sum = i;
        }
        cout << sum;
    }
}

Measured memory_bytes: 256
using System;

namespace Problem_C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            long n = inputs[0], m = inputs[1];
            if (n == 1 && m == 1) Console.WriteLine("1");
            else if (n == 1) Console.WriteLine($"{m - 2}");
            else if (m == 1) Console.WriteLine($"{n - 2}");
            else Console.WriteLine($"{(n - 2) * (m - 2)}");
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    Int N, X; cin >> N >> X;
    vector<Int> B(N), L(N), U(N);
    for (int i = 0; i < N; i++) cin >> B[i] >> L[i] >> U[i];
    Int start = 0;
    for (int i = 0; i < N; i++) start -= B[i] * L[i];
    vector<pair<Int, int>> A(N);
    for (int i = 0; i < N; i++) A[i] = make_pair(U[i] * (X - B[i]) + L[i] * B[i], i);
    sort(rbegin(A), rend(A));
    vector<Int> S(N+1), order(N);
    for (int i = 0; i < N; i++) order[A[i].second] = i;
    for (int i = 0; i < N; i++) S[i+1] = S[i] + A[i].first;
    Int ok = X * N, ng = -1;
    while (ok - ng > 1) {
        Int mid = (ok + ng) / 2;
        int s = mid / X;
        int t = mid % X;
        Int maxval = start;
        for (int i = 0; i < N; i++) {
            Int val = start + (t > B[i] ? U[i] : L[i]) * (t - B[i]) + L[i] * B[i];
            if (order[i] < s) {
                val += S[s+1] - (U[i] * (X - B[i]) + L[i] * B[i]);
            } else {
                val += S[s];
            }
            maxval = max(maxval, val);
        }
        (maxval >= 0 ? ok : ng) = mid;
    }
    cout << ok << '\n';
    return 0;
}


Measured memory_bytes: 5760
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	//	static long start;
	//	static long end;

	public static void main(String[] args) {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int[] a = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = scan.nextInt();
		}

		int ret = Integer.MAX_VALUE;
		for (int i = 0; i < 2; i++) {
			for (int j = i + 1; j < 3; j++) {
				if (a[i] + a[j] < ret) {
					ret = a[i] + a[j];
				}
			}

		}

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

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21332
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>
 
#define INF 100000000
#define EPS 1e-9
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
  
#define MAX_S 1000

int x, y, s;

vector<int> ans_list;

int calc(int num, int per){
  
  return num*(100 + per)/100;

}

int main(){
  
  while(true){
    
    cin >> x >> y >> s;
    if(x == 0)
      break;

    int ans = 0;

    for(int i = 1; i <= 1000; i++){
      for(int j = 1; j <= 1000; j++){
	if(calc(i,x) + calc(j,x) != s)
	  continue;
	ans = max(ans,calc(i,y) + calc(j,y));
      }
    }

    ans_list.push_back(ans);

  }  

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

  return 0;
  
}

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

constexpr int INF = 1e9;

int h, w;
bool m[20][20];
pair<int, int> directions[4] = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } };

int find(int r, int c) {
	queue<pair<int, int>> q;
	q.push({ r, c });

	int d[20][20];
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			d[i][j] = -1;
		}
	}

	d[r][c] = 0;

	int mx = 0;
	while (!q.empty()) {
		pair<int, int> p = q.front();
		q.pop();

		for (int i = 0; i < 4; ++i) {
			pair<int, int> dir = directions[i];
			int rd = p.first + dir.first;
			int cd = p.second + dir.second;
			int nd = d[p.first][p.second] + 1;

			if (rd >=0 && rd < h && cd >= 0 && cd < w && m[rd][cd] && (d[rd][cd] == -1 || d[rd][cd] > nd)) {
				q.push({ rd, cd });
				d[rd][cd] = d[p.first][p.second] + 1;
				mx = max(mx, d[rd][cd]);
			}
		}
	}

	return mx;
}

int main() {
	cin >> h >> w;

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			m[i][j] = false;
		}
	}

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			char c;
			cin >> c;

			m[i][j] = c == '.';
		}
	}

	int ans = 0;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (m[i][j]) {
				ans = max(ans, find(i, j));
			}
		}
	}

	cout << ans;
	
	return 0;
}
	

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

#define MAX 100000+5
#define NIL -1

struct Node {
    int parent;
    int left;
    int right;
};

Node T[MAX];
int n, D[MAX];

void Print( int u );
int Rec( int u, int p );

int main() {
    cin >> n;
    for ( int i = 0; i < n; ++i ) T[i].parent = T[i].left = T[i].right = NIL;
    
    int v, d, l;
    for ( int i = 0; i < n; ++i ) {
        cin >> v >> d;
        int c;
        for ( int j = 0; j < d; ++j ) {
            cin >> c;
            if ( 0 == j ) T[v].left = c;
            else T[l].right = c;
            l = c;
            T[c].parent = v;
        }
    }
    
    int r;
    for ( int i = 0; i < n; ++i ) {
        if ( T[i].parent == NIL ) {
            r = i;
        }
    }
    
    Rec( r, 0 );
    
    for ( int i = 0; i < n; ++i ) Print( i );
    
    return 0;
}

void Print( int u ) {
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";
    
    if ( NIL == T[u].parent ) cout << "root, ";
    else if ( NIL == T[u].left ) cout << "leaf, ";
    else cout << "internal node, ";
    
    cout << "[";
    int flag = 0;
    for ( int c = T[u].left; c != NIL; c = T[c].right ) {
        if ( flag++ ) cout << ", ";
        cout << c;
    }
    cout << "]\n";
}

int Rec( int u, int p ) {
    D[u] = p;
    if ( NIL != T[u].right ) Rec( T[u].right, p );
    if ( NIL != T[u].left ) Rec( T[u].left, p+1 );
}

Measured memory_bytes: 7776
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int r,g,b;
	int n;
	cin>>r>>g>>b>>n;
	int num=0;
	for(int x=0;x<=n/r;x++)
	   for(int y=0;y<=n/g;y++)
	   {
	   	int z=n-r*x-g*y;
	   	if(z>=0&&z%b==0)num++;
	   }
	   
	cout<<num;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
	cin >> N;
	vector<pair<int, int>> v(N);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		v[i] = make_pair(a, i+1);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < N; i++) {
		cout << v[i].second;
		cout << ((i == N-1) ? '\n' : ' ');
	}
}


Measured memory_bytes: 1536
s = input()

MOD = 10 ** 9 + 7

# dp[0 .. len(s)][0..3] = その状態の数
dp = [[0 for _ in range(3 + 1)] for _ in range(len(s) + 1)]
dp[0][0] = 1

for i in range(1, len(s) + 1):
    # s[i]を取らない
    dp[i][0] += dp[i - 1][0] * (3 if s[i - 1] == '?' else 1)
    dp[i][1] += dp[i - 1][1] * (3 if s[i - 1] == '?' else 1)
    dp[i][2] += dp[i - 1][2] * (3 if s[i - 1] == '?' else 1)
    dp[i][3] += dp[i - 1][3] * (3 if s[i - 1] == '?' else 1)

    # s[i]を取る
    if s[i - 1] == 'A':
        dp[i][1] += dp[i - 1][0]
    elif s[i - 1] == 'B':
        dp[i][2] += dp[i - 1][1]
    elif s[i - 1] == 'C':
        dp[i][3] += dp[i - 1][2]
    elif s[i - 1] == '?':
        dp[i][1] += dp[i - 1][0]
        dp[i][2] += dp[i - 1][1]
        dp[i][3] += dp[i - 1][2]

    for j in range(3 + 1):
        dp[i][j] %= MOD

print(dp[len(s)][3])

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

#define MOD 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_V 100
#define MAX_E 100

//--------------------------

ll N, res;

ll A[MAX_N+1];
ll B[MAX_N];

int main() {

  cin >> N;
  rep(i, N+1) cin >> A[i];
  rep(i, N) cin >> B[i];

  rep(i, N) {
    if(B[i]>=A[i]) {
      res += A[i];
      B[i] -= A[i];
    }else {
      res += B[i];
      B[i] = 0;
    }

    if(B[i]>0) {
      if(B[i]>=A[i+1]) {
        res += A[i+1];
        A[i+1] = 0;
      }else {
        res += B[i];
        A[i+1] -= B[i];
      }
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main()
{


    string S;

    std::cin >> S;

    if(S[0]==S[1])
        if(S[1]!=S[2] && S[1]!=S[3] &&  S[2]==S[3])
            cout << "Yes" << std::endl;
        else
            cout << "No" << std::endl;
    else if(S[0]==S[2])
        if(S[0]!=S[1] && S[0]!=S[3] && S[1]==S[3])
            cout << "Yes" << std::endl;
        else
            cout << "No" << std::endl;
    else if(S[0]==S[3])
        if(S[0]!=S[1] && S[0]!=S[2] && S[1]==S[2])
            cout << "Yes" << std::endl;
        else
            cout << "No" << std::endl;
    else
        cout <<"No"<<std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

ll ax(ll a, ll x){
  if (x == 0){
    return 1;
  }else{
    ll A = a * a; A = A % nmax;
    if (x % 2 == 0){
      return (ax(A, x/2)) % nmax;
    }else{
      return ((ax(A, x/2)) % nmax) * a % nmax;
    }
  }
}



ll nCr(ll n, ll r){
  ll ans = 1;
  if (r >= n / 2){
    r = n - r;
  }
  
  for (int i = 1; i <= r; i++){
    ans = ans * (n + 1 - i); ans = ans % nmax;
    ans = ans * ax(i, nmax - 2); ans = ans % nmax;
  }
  return ans;

}

int main(){
  
  ll K[200001], k[200001];
  K[0] = 1, k[0] = 1;
  for (int i = 1; i < 200001; i++){
    K[i] = i * K[i - 1]; K[i] = K[i] % nmax;
    k[i] = ax(K[i], nmax - 2);
  }

  ll H, W, A, B; cin >> H >> W >> A >> B;
  
  ll ans = 0;
  for (int i = 1; i <= H - A; i++){
    ll sum = K[B + i - 2]; sum = sum % nmax;
    sum = sum * k[B - 1]; sum = sum % nmax;
    sum = sum * k[i - 1]; sum = sum % nmax;
    sum = sum * K[W - B - 1 + H - i]; sum = sum % nmax;
    sum = sum * k[W - B - 1]; sum = sum % nmax;
    sum = sum * k[H - i]; sum = sum % nmax;
    ans += sum; ans = ans % nmax;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>

using namespace std;

int main(void){
    int N;
    cin>>N;

    if(N<1000){
        cout<<"ABC"<<endl;
        return 0;
    }else{
        N=N-1000;
        cout<<"ABD"<<endl;
        return 0;
    }


    return 0;
}


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

int main() {
  vector<int> vec(4);
  rep(i, 4) cin >> vec[i];
  sort(vec.begin(), vec.end());
  if (vec[0] == 1 && vec[1] == 4 && vec[2] == 7 && vec[3] == 9) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

struct Node {
  Node* parent;
  Node* left;
  Node* right;
  int value;
  Node() : parent(NULL), left(NULL), right(NULL), value(-1) {
  }
};

Node* root = NULL;

void insert(int value) {
  if(root == NULL) {
    root = new Node();
    root->value = value;
    return;
  }

  Node* parent = root;
  Node* node = root;
  int left = 0;
  while(node != NULL) {
    parent = node;
    if(node->value < value) {
      left = 0;
      node = node->right;
    } else {
      left = 1;
      node = node->left;
    }
  }

  Node* newNode = new Node();
  newNode->value = value;
  newNode->parent = parent;
  if(left == 1) {
    parent->left = newNode;
  } else {
    parent->right = newNode;
  }
}

void printInOrder(Node* n) {
  if(n->left != NULL)
    printInOrder(n->left);
  cout << " " << n->value;
  if(n->right != NULL)
    printInOrder(n->right);
}

void printPreOrder(Node* n) {
  cout << " " << n->value;
  if(n->left != NULL)
    printPreOrder(n->left);
  if(n->right != NULL)
    printPreOrder(n->right);
}

void print() {
  printInOrder(root);
  cout << endl;
  printPreOrder(root);
  cout << endl;
}

void find(int value) {
  Node* n = root;
  while(n != NULL) {
    if(n->value == value) {
      cout << "yes" << endl;
      return;
    } else if(n->value < value) {
      n = n->right;
    } else {
      n = n->left;
    }
  }
  cout << "no" << endl;
}

int main() {
  int n;
  cin >> n;
  for(int i=0; i<n; i++) {
    string op;
    cin >> op;

    if(op.compare("insert") == 0) {
      int value;
      cin >> value;

      insert(value);
    } else if(op.compare("print") == 0) {
      print();
    } else if(op.compare("find") == 0) {
      int value;
      cin >> value;

      find(value);
    } else {
      cout << "unknown op: " << op << endl;
      return 1;
    }
  }
  return 0;
}

Measured memory_bytes: 21796
N,K,Q=map(int,input().split(" "))
A=[int(input()) for _ in range(Q)]
T=[0 for _ in range(N)]

for i in range(Q):
    T[A[i]-1]=T[A[i]-1]+1
for i in range(N):
    T[i]=T[i]-(Q-K)
    if T[i]<=0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 56536
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

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

    string s;
    cin >> s;

    int res[SIZE] = {};
    vector< P > v;
    int cnt = 0;
    for( int i = 0; i < s.size() - 1; ++i ) {
        cnt++;
        if( s[i] != s[i + 1] ) {
            v.pb( MP( cnt, i ) );
            cnt = 0;

        }
    }
    ++cnt;
    v.pb( MP( cnt, s.size() - 1 ) );

    for( int i = 0; i < v.size() - 1; ++i ) {
        res[v[i].S] += v[i].F / 2 + v[i].F % 2;
        res[v[i].S + 1] += v[i].F / 2;
        res[v[i].S + 1] += v[i + 1].F / 2 + v[i + 1].F % 2;
        res[v[i].S] += v[i + 1].F / 2;
        ++i;

    }

    for( int i = 0; i < s.size(); ++i ) {
        cout << res[i] << " ";

    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1864
#include <bits/stdc++.h>
#define pb push_back
#define tam 5120
#define offset 320000
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(ll i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000009 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<(a*3+b)/2<<endl;
}

Measured memory_bytes: 256
/*
AizuOnline A1137
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int N;
char num1[20];
char num2[20];
char kigou[4]="mcxi";
int value[4]={1000,100,10,1};
char outbuf[20];
//
int mcxi2num(char * s)
{
  int sum=0,v,i;
  char *p;

  for(i=0;i<strlen(s);i++)
    if(p=strchr(kigou,s[i]))
      {
	v=value[p-kigou];
      if(i>0 && isdigit(s[i-1]))
	sum +=(v*(s[i-1]-'0'));
      else	
	sum += v;
      }
  return(sum);
}
void num2mcxi(int num,char *s)
{
  int v,i;

  if(num == 0)
    {
      *s='\0';
      return;
    }

  for(i=0;i<4;i++)
    {
      if((v=num / value[i]) > 0)
	{
	  if(v > 1)
	    *s++='0'+v;
	  *s++=kigou[i];
	  num2mcxi(num % value[i],s++);
	  return;
	}
    }
    
}
main()
{
  int sum,i;

  while(EOF != scanf("%d ",&N) && N)
    {
      for(i=0;i<N;i++)
	{
	  scanf("%s %s",num1,num2);
	  //printf("%s %d\n",num1,mcxi2num(num1));
	  sum = mcxi2num(num1) + mcxi2num(num2);
	  num2mcxi(sum,outbuf);
	  printf("%s\n",outbuf);
	}
    }
return(0);
}

Measured memory_bytes: 592
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define MOD 1e9 + 7
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265359

void Main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double hx, hy, mx, my;
    hx = a * cos(2 * PI * ((h / 12.0) + (m / 720.0)));
    hy = a * sin(2 * PI * ((h / 12.0) + (m / 720.0)));
    mx = b * cos(2 * PI * (m / 60.0));
    my = b * sin(2 * PI * (m / 60.0));

    cout << sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my)) << endl;

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4120
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
int h, w;
char s[1111][1111];
char temp[1111];
bool hc=false, vc=false;
ll u, v;
ll up, vp;
ll a, b, c, k;
ll st[64][4];
ll ans[4];
ll fin;
ll tans[4];

ll exp(ll n, ll po)
{
	if(po==0)
	{
		return 1;
	}
	if(po==1)
	{
		return n;
	}
	if(po%2==0)
	{
		return exp((n*n)%mod,po/2);
	}
	if(po%2==1)
	{
		return (n*exp((n*n)%mod,po/2))%mod;
	}
}

int main(void)
{
	cin>>h>>w>>k;
	int i, j;
	for(i=1 ; i<=h ; i++)
	{
		scanf("%s",&temp[1]);
		for(j=1 ; j<=w ; j++)
		{
			s[i][j]=temp[j];
			a+=(s[i][j]=='#');
		}
		for(j=1 ; j<=w-1 ; j++)
		{
			if(s[i][j]=='#' && s[i][j+1]=='#')
			{
				u++;
			}
		}
		if(s[i][1]=='#' && s[i][w]=='#')
		{
			hc=true;
			up++;
		}
	}
	for(i=1 ; i<=w ; i++)
	{
		if(s[1][i]=='#' && s[h][i]=='#')
		{
			vc=true;
			vp++;
		}
		for(j=1 ; j<=h-1 ; j++)
		{
			if(s[j][i]=='#' && s[j+1][i]=='#')
			{
				v++;
			}
		}
	}
	if(hc==true && vc==true)
	{
		cout<<1; 
		return 0;
	}
	if(hc==false && vc==false)
	{
		cout<<exp(a,k-1);
		return 0;
	}
	if(hc==true)
	{
		b=u;
		c=up;
	}
	else
	{
		b=v;
		c=vp;
	}
	b=mod-b;
	st[0][0]=a;
	st[0][1]=b;
	st[0][2]=0;
	st[0][3]=c;
	for(i=1 ; i<=62 ; i++)
	{
		st[i][0]=((st[i-1][0]*st[i-1][0])%mod+(st[i-1][1]*st[i-1][2])%mod+2*mod)%mod;
		st[i][1]=((st[i-1][0]*st[i-1][1])%mod+(st[i-1][1]*st[i-1][3])%mod+2*mod)%mod;
		st[i][2]=((st[i-1][0]*st[i-1][2])%mod+(st[i-1][2]*st[i-1][3])%mod+2*mod)%mod;
		st[i][3]=((st[i-1][1]*st[i-1][2])%mod+(st[i-1][3]*st[i-1][3])%mod+2*mod)%mod;
	}
	k--;
	ans[0]=1; ans[3]=1;
	for(i=0 ; i<=62 ; i++)
	{
		if((k&(1LL<<i))==(1LL<<i))
		{
			tans[0]=ans[0];
			tans[1]=ans[1];
			tans[2]=ans[2];
			tans[3]=ans[3];
			ans[0]=((tans[0]*st[i][0])%mod+(tans[1]*st[i][2])%mod+2*mod)%mod;
			ans[1]=((tans[0]*st[i][1])%mod+(tans[1]*st[i][3])%mod+2*mod)%mod;
			ans[2]=((tans[2]*st[i][0])%mod+(tans[3]*st[i][2])%mod+2*mod)%mod;
			ans[3]=((tans[2]*st[i][1])%mod+(tans[3]*st[i][3])%mod+2*mod)%mod;
		}
	}
	fin=(ans[0]+ans[1]+2*mod)%mod;
	cout<<fin;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    string S;
    cin >> S;
    cout << S[0] << S[1] << S[2] << "\n";
}


Measured memory_bytes: 3612
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0) break;
			else calc(n);
		}
	}
	public void calc(int n){
		int t = 24 * 60 * 60 + 1;
		int[] time = new int[t];
		for(int i = 0; i < n; i++){
			String Dep = sc.next();
			String[] Deps = Dep.split(":");
			int d = Integer.valueOf(Deps[0]) * 60 * 60 + Integer.valueOf(Deps[1]) * 60 + Integer.valueOf(Deps[2]);
			time[d] = time[d] + 1;
			
			String Out = sc.next();
			String[] Outs = Out.split(":");
			int o = Integer.valueOf(Outs[0]) * 60 * 60 + Integer.valueOf(Outs[1]) * 60 + Integer.valueOf(Outs[2]);
			time[o] = time[o] - 1;
		}
		
		int max = 0;
		for(int i = 1; i < t; i++){
			time[i] = time[i] + time[i-1];
			if(max < time[i]) {
				max = time[i];
			}
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 100072
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;


//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

bool check(string s){
  int n = s.length();
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[n/2+i]) return false;
  }
  return true;
}

int count(string *s){
  int count = 0;
  /*
  REP(i,h){
    REP(j,w){
      if( s[i][j] == '#') count++;
    }
  }*/
  return count;
}

int main(void){

  ll n;
  cin >> n;
  ll a[n];
  REP(i,n){
    cin >> a[i];
  }
  sort(a, a + SIZE_OF_ARRAY(a), greater<>());
  ll ans = 0;
  map<ll,ll> m;
  m[a[0]] = 1;
  ll now = a[0];
  ll tmp = a[0];
  for(ll i=1;i<(ll)(n);i++){
    if( a[i] < now ){
      m[a[i]] = m[now];
      now = a[i];
    }
    m[a[i]] += 1;
    if( i+1-m[tmp] > m[tmp] ){
      auto itr = m.find(tmp);
      tmp = prev(itr)->first;
    }
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}
// 3 3 2 2 2 2 1 1 1 1 1

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int a[3], ans = 0; REPI(i, 3) cin >> a[i];
    sort(a, a + 3);
    REPI(i, 2) if(a[i] - a[i + 1]) ans++;
    cout << ans + 1;
}


Measured memory_bytes: 256
# 約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

A, B = map(int, input().split())
ptn = list(reversed(make_divisors(A * B)))

for i in range(0, len(ptn), 2):
    if ptn[i] % A == 0 and ptn[i] % B == 0:
        print(ptn[i])
        exit()
print(A * B)

Measured memory_bytes: 3064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <cassert>
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

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

	int n, m, a, b;

	cin >> n >> m;
	dsu uf(n);
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		a -= 1;
		b -= 1;
		uf.merge(a, b);
	}

	int res = uf.groups().size();

	cout << res - 1 << '\n';

	return 0;
}

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

int main()
{
  int n, k;
  cin >> n;
  vector <vector<int>> matrix(n, vector<int> (3));
  for(int i=0; i < n; i++)
  {
    for(int j=0; j < 3; j++)
    {
      cin >> matrix[i][j];
    }
  }
  vector <vector<int>> dp(n, vector<int> (3));
  dp[0][1] = matrix[0][1];
  dp[0][0] = matrix[0][0];
  dp[0][2] = matrix[0][2];
  for(int i=1; i < n; i++)
  {
    for(int j=0; j < 3; j++)
    {
      if(j == 0)
      	dp[i][j] = matrix[i][j] + max(dp[i-1][1], dp[i-1][2]);
      else if(j == 1)
      	dp[i][j] = matrix[i][j] + max(dp[i-1][0], dp[i-1][2]);
      else
      	dp[i][j] = matrix[i][j] + max(dp[i-1][0], dp[i-1][1]);
    }
  }
  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
  return 0;
}

Measured memory_bytes: 11136
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"
using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0}, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
typedef struct {int x;int y;}cod;

int fl[26];


int main() {
	char s[30];
	
	int l;
	int c = 0;
	
	cin >> s;
	l = strlen(s);
	if (l == 26) {
		c = l-1;
		while ((s[c - 1] > s[c])) {
			c--;
			if (c == 0) {
				printf("-1");
				return 0;
			}
		}
		for (int i = l-1;i >= c;i--) {
			//if (i == -1) { return 0; }
			if (s[c - 1] < s[i]) {
				s[c - 1] = s[i];
				s[c] = '\0';
				printf("%s", s);
				return 0;
			}

		}

	}
	else {
		fori0(l) {
			fl[s[i] - 'a'] = 1;
		}
		fori0(25) {
			if (fl[i] == 0) {
				s[l] = 'a' + i;
				s[l + 1] = '\0';
				printf("%s", s);
				return 0;
			}
		}
	}
	
	//cout << c << endl;
	printf("%s", s);
	system("pause");
	return 0;
}


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

int main(){
    long long a;
    cin>>a;
    vector<long long>v(2*a);
    for(long long i=0;i<2*a;i++){
         cin>>v[i];
    }
    priority_queue<long long> p(v.begin(),v.end());
    long long sum=0;
    while(!p.empty()){
        p.pop();
        sum+=p.top();
        p.pop();
    }
    cout<<sum;
}

Measured memory_bytes: 888
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int dp[2][2][4][4];
char c[100010];

int main(){
	while(scanf("%s",c)){
		if(c[0]=='#')break;
		memset(dp,0,sizeof(dp));
		int n=strlen(c);
		rep2(i,1,n+1){
			int cur=i%2,pre=1-cur,a=(c[i-1]-'0')%3;
			if(!a)a=3;
			rep(j,2)rep(k,4)rep(l,4)dp[cur][j][k][l]=INF;
			rep(j,2)rep2(k,1,4)rep2(l,max(k,a),4){
				dp[cur][0][a][l]=min(dp[cur][0][a][l],dp[pre][j][k][l]+(j<1));
			}
			rep(j,2)rep2(k,1,a+1)rep2(l,k,4){
				dp[cur][1][k][a]=min(dp[cur][1][k][a],dp[pre][j][k][l]+(j>0));
			}
		}
		int a=INF;
		rep(i,2)rep(j,4)rep(k,4)a=min(a,dp[n%2][i][j][k]);
		cout<<a<<endl;
	}
}

Measured memory_bytes: 984
int main(void)
{
  int a,b,c;
  
  scanf("%d%d%d", &a, &b, &c);
  
  for(int i=0; i<(a-b); i++)
  {
    if(c==0)
      break;
    c--;
  }
    printf("%d", c);
  
  return(0);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    vector<int> a(3);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[0]>>a[1]>>a[2];
        sort(a.begin(),a.end());
        if(a[2]*a[2]==a[0]*a[0]+a[1]*a[1])cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

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

int main() {
  string s;cin>>s;
  int cnt0=0,cnt1=0;
  rep(i,s.size()){
    if(s[i]=='0')cnt0++;
    else cnt1++;
  }
  int ans=min(cnt0*2,cnt1*2);
  cout<<ans<<endl;
}

Measured memory_bytes: 3748