akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	int N, M; cin >> N >> M;
	vi v_ac(N, 0);
	vi v_wa(N, 0);
	veb boo(N, false);

	int ac = 0, wa = 0;
	rep(i,M) {
		int p; string s; cin >> p >> s; p--;
		if(v_ac[p] == 0 and s == "WA") v_wa[p]++;
		if(v_ac[p] == 0 and s == "AC") { v_ac[p]++; wa += v_wa[p]; ac++; }


		//if(v[p] == 0 and s == "AC") { boo[p] = true; ac++; v[p]++; }
	}
	cout << ac << " " << wa << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> A(n);
	for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
	for (int i = 0; i < k; ++i) {
		vector<int> D(n + 1);
		for (int j = 0; j < n; ++j) {
			D[max(0, j - A[j])]++;
			D[min(n, j + A[j] + 1)]--;
		}
		bool no = false;
		for (int i = 0; i < n; ++i) {
			if (i) A[i] = A[i - 1];
			else A[i] = 0;
			A[i] += D[i];
			if (A[i] < n) no = true;
		}
		if (!no) break;
	}
	for (int i = 0; i < n; ++i) printf("%d ", A[i]);
}


Measured memory_bytes: 4892
#include "bits/stdc++.h"
#define ll long long
#define fr first
#define sc second
using namespace std;

const int mnx = 1e7 + 9;
const int mod = 1e9 + 7;
const double PI = acos(-1);

ll n, a, b, h[mnx];

ll f(int x){
    ll res = 0;

    for(int i = 1; i <= n; i++){
        ll hh = h[i] - x * b;
        if(hh > 0) res += (hh + (a - b) - 1) / (a - b);
    }

    return (res <= x);
}

void solve(){
    cin >> n >> a >> b;

    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }

    ll l = 0, r = mod;

    while(l + 1 < r){
        int mid = (l + r) >> 1;

        if(f(mid)) r = mid;
        else l = mid;
    }

    cout << r << '\n'
;}


int main(){
//    ios_base::sync_with_stdio(0);
//    cin.tie(0), cout.tie(0);
    ll tt = 1;

//    scanf("%d", &tt);

    while(tt--){
        solve();
    }

    return 0;
}


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

char s[101];
bool flag;
int Cdir;

int main()
{
	scanf("%s",s);
	for(int i = 0;s[i] != '\0';i++){
		if(s[i] == 'C'){
			flag = true;
			Cdir = i;
			break;
		}
	}
	if(flag)
		for(int i = Cdir + 1;s[i] != '\0';i++){
			if(s[i] == 'F'){
				cout<<"Yes";
				return 0;
			}
		}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
def draft(A, K, N):
    for _ in range(1, K+1):# 2 * 10**5
        tmp = [0]*(N+1)
        for i in range(N):# 2 * 10**5
            L = max(0, i - A[i])
            R = min(N, i + A[i]+1)
            tmp[L] += 1
            tmp[R] -= 1
        f = True
        for i in range(N):
            tmp[i+1] += tmp[i]
            A[i] = tmp[i]
            if A[i] != N:
                f = False
        if f:
            break
    for i in range(N):
        print(A[i], end=" ")

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    draft(A, K, N)

if __name__ == "__main__":
    main()


Measured memory_bytes: 104244
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t H;
  cin >> H;
  int64_t a=1;
  int64_t i=0;
  while(H>1){
    H=H/2;
    i+=a;
    a=a*2;
  }
  i+=a;
  cout <<i<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        String a[] = sc.next().split("");
     	String b[] = sc.next().split("");
        String c[] = sc.next().split("");
        

        if(a[a.length - 1].equals(b[0])  && b[b.length - 1].equals(c[0])){
          System.out.println("YES");
        }else{
          System.out.println("NO");
        }

    }
}

Measured memory_bytes: 35628
#include <iostream>
#include <string>

int main() {
  std::string S;
  std::cin >> S;
  bool is_hitachi_literal = true;
  int length = S.length();
  if (length % 2 == 1) {
    is_hitachi_literal = false;
  }
  for(int i = 0; i < length; i=i+2) {
    if(S[i] != 'h' || S[i+1] != 'i') {
      is_hitachi_literal = false;
      break;
    }
  }
  if (is_hitachi_literal) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
function main(input) {
   input = input.trim();
  const a = input.split("\n").map(Number);
  if(a[0]==1){
   console.log("Hello World");

 }else {
	console.log(a[1]+a[2]);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30372
package main

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

var sc *bufio.Scanner

func nextString() string {
	sc.Scan()
	i := sc.Text()
	return i
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func printList(a []trump) {
	for i, v := range a {
		fmt.Printf("%s%d", v.kind, v.value)
		if i == len(a)-1 {
			fmt.Print("\n")
		} else {
			fmt.Print(" ")
		}
	}
}

type trump struct {
	kind  string
	value int
}

func selectionSort(a []trump) ([]trump, int) {
	count := 0
	minj := 0
	for i := range a {
		minj = i
		for j := i; j < len(a); j++ {
			if a[minj].value > a[j].value {
				minj = j
			}
		}
		if i != minj {
			a[i], a[minj] = a[minj], a[i]
			count++
		}
	}
	return a, count
}

func babbleSort(a []trump) ([]trump, int) {
	count := 0
	flag := true
	for flag {
		flag = false
		for i := len(a) - 1; i >= 1; i-- {
			if a[i].value < a[i-1].value {
				a[i], a[i-1] = a[i-1], a[i]
				flag = true
				count++
			}
		}
	}
	return a, count
}

func sliceEqual(a, b []trump) bool {
	flag := true
	for i, v := range a {
		if v.kind != b[i].kind || v.value != b[i].value {
			flag = false
			break
		}
	}
	return flag
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]trump, n)
	b := make([]trump, len(a))
	var input string
	for i := range a {
		input = nextString()
		a[i].kind = input[:1]
		a[i].value, _ = strconv.Atoi(input[1:])
	}
	copy(b, a)
	a, _ = babbleSort(a)
	b, _ = selectionSort(b)
	printList(a)
	fmt.Println("Stable")
	printList(b)
	if sliceEqual(a, b) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}



Measured memory_bytes: 1116
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int a[100005];
int b[100005];
int main(void){
    int n; cin>>n;
    int i=0;
    while(n!=0){
        a[i]=abs(n%(-2));
        if(n==1){
            break;
        }
        if(n%(-2)!=0&&n<0){
            n=n/(-2)+1;
        }else{
            n=n/(-2);
        }
        i++;
    }
    while(i>=0){
        cout<<a[i]; i--;
    }
    cout<<endl;
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/
signed main(){
	ll a,b;
	cin >> a >> b;
	string s;
	cin >> s;
	
	s[b-1] -= 'A' - 'a';
	
	cout << s << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	long long ans=1;
	if(n==m){
		ans=1;
		for(int i=1;i<=n;i++)ans=ans*i%1000000007;
		for(int i=1;i<=m;i++)ans=ans*i%1000000007;
		ans=ans*2%1000000007;
	}
	else if(n==m+1||m==n+1){
		ans=1;
		for(int i=1;i<=n;i++)ans=ans*i%1000000007;
		for(int i=1;i<=m;i++)ans=ans*i%1000000007;
	}
	else
		ans=0;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n+1), b(n+1);
    b[0] = 1LL;
    ll ans = 0LL;
    bool cnt = true;
    for(ll i=0LL;i<=n;i++){
    	cin >> a[i];
    	if(cnt){
    	    if(i == 0LL) b[i] -= a[i];
    	    else b[i] = b[i-1] * 2LL - a[i];
    	    if(b[i] < 0LL){
    		    cout << -1 << endl;
    		    return 0;
    	    }
    	    if(b[i] > INF) cnt = false;
        }else b[i] = INF;
    }
    ll now = a[n];
    ans += now;
    for(ll i=n-1;i>=0;i--){
    	now = min(now, b[i]) + a[i];
    	ans += now;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4780
import math
N  = int(input())
左端 = [False] * (N + 1)
参照 = [False] * (N + 1)
places = [-1] * ( N + 1)
for ind in range(N):
    temp = int(input())
    places[temp] = ind
for num in range( 1,N + 1):
    if 参照[num] == False:
        左端[num] = True
        l = 1
        while True:
            if num + l <= N and places[num+ l - 1] < places[num + l]:
                参照[num + l] = True
                l += 1
            else:
                break

hoge = 0
for i in range(1 ,N  + 1):
    if 左端[i]:
        cot = 1
        l = i + 1
        while True:
            if l <= N and 参照[l]  :
                cot += 1
                l += 1
            else:
                break
        hoge = max(cot,hoge)
print(N - hoge)

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);
#define PI 3.141592654

using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; }return ans; }
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 modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) { x = (x + v) % MOD; if (x < 0) x += MOD; }
//ll f[500005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


void test_case() {

}

vector<pair<ll, ll>> factorize(ll n) {
	vector<pair<ll, ll>> ans;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) {
			ll count = 0;
			while (n % i == 0) {
				n /= i;
				++count;
			}
			ans.push_back({ i, count });
		}
	}
	if (n > 1) {
		ans.push_back({ n, 1 });
	}
	return ans;
}

int main() {
	fastio;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	ll N;
	cin >> N;
	auto f = factorize(N);
	ll ans = 0;
	for (auto p : f) {
		for (int i = 1; p.second >= i; ++i) {
			++ans;
			p.second -= i;
		}
	}
	cout << ans;
	return 0;
}


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


void solve(string S){
    vector<int> dp(2019,0);
    int res = 0;
    int digit =1;
    dp[0] = 1;
    for (int i=0;i<S.size();i++){
        res= digit* (S[S.size()-i-1] -'0') + res;
        res %=2019;
        digit = (digit * 10) %2019;
        dp[res] +=1;
    }
    long long ans = 0;
    for (int i=0;i<2019;i++){
        ans+= dp[i] * (dp[i]-1) /2;
    }
    printf("%lld\n",ans);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3924
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
	int n,q;
	cin >> n >> q;
	int a[n];
	for(int i=0;i<n;++i)
	cin >> a[i]; 
	Query queries[q]; 
	for(int i=0;i<q;++i)
	{
		cin >> queries[i].l >> queries[i].r;
		queries[i].l--;
		queries[i].r--;
		queries[i].idx = i;
	}
	sort(queries, queries+q, cmp); 
	answeringQueries(a, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 19340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
   ll n,k;
   cin>>n>>k;
   ll ans=abs(n-(n/k)*k);
   ans=min(ans,abs(n-(n/k+1)*k));
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int f[5][5],i,j,a;
int main()
{
	for(;i<9;++i){
		char s[6];
		scanf("%s",s);
		for(j=0;j<4+i%2;++j){
			a=s[j]-48;
			f[i/2][j]|=a<<(1+i%2);
			f[i/2+i%2][j+!(i%2)]|=a<<3-i%2*3;
		}
	}
	int y=0,x=0,p=2;
	do{
		p=(p+2)%4;
		int d=p;
		do
			d=(d+1)%4;
		while(!((f[y][x]>>d)&1));
		p=d;
		putchar("URDL"[d]);
		x+=p?2-p:0;
		y+=p==3?0:p-1;
	}while(y!=0||x!=0||f[0][0]==6&&p==3);
	puts("");
	return 0;
}

Measured memory_bytes: 0
from scipy.misc import comb
import math
mod = 10**9 + 7

N, M = map(int, input().split())
if abs(N - M) > 1:
    print(0)
else:
    if abs(N - M) == 1:
        print(((math.factorial(N) % mod) * (math.factorial(M) % mod)) % mod)
    else:
        print(((math.factorial(N) % mod) * ((math.factorial(M) * 2) % mod)) % mod)

Measured memory_bytes: 15740
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)
	if A+B-1 > N || A*B < N {
		fmt.Println(-1)
		return
	}
	x := N - A
	m := 0
	for m < N {
		y := 0
		if x >= B-1 {
			y = B
		} else {
			y = x + 1
		}
		for i := m + y; i > m; i-- {
			fmt.Printf("%d ", i)
		}
		m += y
		x -= y - 1
	}
}


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

int main() {
  int N, K; cin >> N >> K;
  int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  long min_cost = (1L<<60);
  for (int b = 0; b < (1<<N); b++) {
    long cost = 0;
    int max_h = 0;
    int color_num = 0;
    int B[N]; for (int i = 0; i < N; i++) B[i] = A[i];
    for (int i = 0; i < N; i++) {
      if (b & (1<<i)) {
        cost += max(0, max_h + 1 - B[i]);
        B[i] = max(B[i], max_h + 1);
        if (B[i] > max_h) color_num++;
      }
      max_h = max(max_h, B[i]);
    }
    if (color_num >= K) min_cost = min(min_cost, cost);
  }
  cout << min_cost << endl;
}

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

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

    int x;
    cin >> x;
    
    int res = 0;
    int num = 1;
    while(num*(num+1) < 2*x){
        res = num;
        ++num;
    }
    cout << res+1 << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())

first = N%10
hon_first = [2, 4, 5, 7, 9]
pon_first = [0, 1, 6, 8]
bon_first = [3]
if first in hon_first:
    print('hon')
elif first in pon_first:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 61904
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;
int main() {
	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		int n = s.find(s[i],i+1);
		if (n != -1) {
			cout << "no" << endl;
			break;
		}
		else if (i == s.length() - 1) {
			cout << "yes" << endl;
		}
	}
}

Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;


// カウンター
template <typename T>
struct Counter {
  map<T, ull> cnt;
  void add(T key) {
    if (cnt.count(key)) {
      cnt[key]++;
    } else {
      cnt[key] = 1;
    }
  }
  void add(vector<T> keys) {
    for (auto key : keys) {
      add(key);
    }
  }
  ll get(T key) {
    if (cnt.count(key)) {
      return cnt[key];
    } else {
      return 0;
    }
  }
  pair<T, ull> max() {
    T key;
    ull mx = 0;
    for (auto kv : cnt) {
      if (kv.second > mx) {
        mx = kv.second;
        key = kv.first;
      }
    }
    return make_pair(key, mx);
  }
  typename map<T, ll>::iterator begin() {
    return cnt.begin();
  }
  typename map<T, ll>::iterator end() {
    return cnt.end();
  }
  typename map<T, ll>::reverse_iterator rbegin() {
    return cnt.rbegin();
  }
  typename map<T, ll>::reverse_iterator rend() {
    return cnt.rend();
  }
};


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

  int N;
  cin >> N;
  Counter<int> c;
  REP(i, N) {
    int a;
    cin >> a;
    c.add(a);
  }
  ll ans = 0;
  for (auto kv : c.cnt) {
    // cout << kv.first << " " << kv.second << endl;
    if (kv.first < kv.second) {
      ans += kv.second - kv.first;
    }
    if (kv.first > kv.second) {
      ans += kv.second;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a==3 || b==3){
        if(a==3) cout << a-b;
        else cout << b-a;
    }
    else cout << a+b;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    map<char,int> mp;
    for(int i = 0; i < s.size(); i++){
        mp[s[i]]++;
    }    
    int a = mp['a'];
    int b = mp['b'];
    int c = mp['c'];
    vector<int> num = {a,b,c};
    sort(num.begin(),num.end(),greater<int>());
    bool flag = true;
    for(int i = 1; i < 3; i++){
        if(num[i] != num[0]-1 && num[i] != num[0]){
            flag = false;
        }
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

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

    vector<bool> AC(N, false);
    vector<int> WA(N);
    // int wa = 0;
    int acSum = 0;
    while (M--)
    {
        int p; string S;
        cin >> p >> S;
        --p;
        if (!AC[p])
        {
            if (S == "WA")
            {
                WA[p]++;
                // wa++;
            } else
            {
                AC[p] = true;
                acSum++;
            }
            
            
        }
        
    }
    int wa = 0;
    for (int i = 0; i < N; i++)
    {
        if (AC[i])
        {
            wa += WA[i];
        }
        
    }
    
    cout << acSum << " " << wa << endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>

using namespace std;

struct dice{
	int q1,q2,q3,q4,q5,q6;
};

void mN(dice &d){
	int tmp=d.q1;
	d.q1=d.q2;
	d.q2=d.q6;
	d.q6=d.q5;
	d.q5=tmp;
}

void mE(dice &d){
	int tmp=d.q1;
	d.q1=d.q4;
	d.q4=d.q6;
	d.q6=d.q3;
	d.q3=tmp;
}
void mW(dice &d){
	int tmp=d.q1;
	d.q1=d.q3;
	d.q3=d.q6;
	d.q6=d.q4;
	d.q4=tmp;
}
void mS(dice &d){
	int tmp=d.q1;
	d.q1=d.q5;
	d.q5=d.q6;
	d.q6=d.q2;
	d.q2=tmp;
}

void spin(dice &d){
	int tmp=d.q2;
	d.q2=d.q3;
	d.q3=d.q5;
	d.q5=d.q4;
	d.q4=tmp;
}

int main(){
	dice y, z;
	bool flag = false;
	
	scanf(" %d %d %d %d %d %d", &y.q1, &y.q2, &y.q3, &y.q4, &y.q5, &y.q6);
	scanf(" %d %d %d %d %d %d", &z.q1, &z.q2, &z.q3, &z.q4, &z.q5, &z.q6);
	
	for(int i=0; i<4; ++i){
		for(int j=0; j<4; ++j){
			//printf("now: %d %d %d %d %d %d\n", y.q1, y.q2, y.q3, y.q4, y.q5, y.q6);
		
			if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
				flag = true;
				break;
			}
			spin(y);	
		}
		if(flag) break;
		mN(y);
	}
	
	mE(y);
	
	//printf("now: %d %d %d %d %d %d\n", y.q1, y.q2, y.q3, y.q4, y.q5, y.q6);
	
	for(int i=0; i<4; ++i){
		for(int j=0; j<4; ++j){
			//printf("now: %d %d %d %d %d %d\n", y.q1, y.q2, y.q3, y.q4, y.q5, y.q6);
		
			if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
				flag = true;
				break;
			}
			spin(y);	
		}
		if(flag) break;
		mN(y);
	}	
			
	if(flag)printf("Yes\n");
	else printf("No\n");
		
	return 0;
}


Measured memory_bytes: 3128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

/**
 * The Number of Island
 */
public class Main {

	final static int LAND = 1;
	final static int VISITED = -1;
	static Queue<Integer> xs, ys;
	static int count;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (true) {

			// load map
			int[][] map = new int[14][14];
			xs = new ArrayDeque<Integer>();
			ys = new ArrayDeque<Integer>();

			for (int i = 1; i < 13; i++) {
				line = br.readLine();
				for (int j = 1; j < 13; j++) {
					map[i][j] = line.charAt(j - 1) - '0';
				}
			}

			// solve
			count = 0;
			for (int i = 1; i < 13; i++) {
				for (int j = 1; j < 13; j++) {
					if (map[i][j] == LAND) {
						xs.add(i);
						ys.add(j);
						while (!xs.isEmpty() && !ys.isEmpty()) {
							visit(map);
						}
						count++;
					}
				}
			}
			// output
			System.out.println(count);

			// next map
			line = br.readLine();
			if (line == null) {
				break;
			} else {
				continue;
			}
		}
	}

	public static void visit(int[][] map) {

		final int[] V = { 1, -1, 0, 0 };
		final int[] H = { 0, 0, 1, -1 };

		int x, y;
		x = xs.remove();
		y = ys.remove();

		if (map[x][y] == LAND) {
			map[x][y] = VISITED;

			// next choices
			for (int i = 0; i < 4; i++) {
				int xv, yh;
				xv = x + V[i];
				yh = y + H[i];
				if (map[xv][yh] == LAND) {
					xs.add(xv);
					ys.add(yh);
				}
			}
		}
	}
}

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

int main(void){
    long long int a, b, c, n, i, j, max=0, ans=0;
    scanf("%lld", &n);
    long long int h[n], hh[n];
    for(i=0; i<n; i++){
        scanf("%lld", &h[i]);
        hh[i] = 0;
    }
    for(i=0; i<n-1; i++) if(h[i]>=h[i+1]) hh[i]++;
    for(i=0; i<n; i++){
        if(hh[i]==1) ans++;
        else{
            if(ans>max) max = ans;
            ans=0;
        }
    }
//    for(i=0; i<n; i++) printf("%lld %lld\n", h[i], hh[i]);
    printf("%lld", max);
    
}

Measured memory_bytes: 1664
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int n;
	int a[101];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	a[n] = 0;
	int ans = 0;
	for (;;)
	{
		int l = -20, r = -20;
		for (int i = 0; i < n+1; i++)
		{

			if (l==-20&&a[i] != 0)
			{
				l = i;
			}
			if (l!=-20&&a[i] == 0)
			{
				r = i-1;
				break;
			}
			


		}
		if (l == -20 || r == -20)
		{
			break;
		}
		for (int i = l; i <= r; i++)
		{
			a[i]--;

		}
		ans++;
		
	}
	cout << ans << endl;
}

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


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//M 77 || //A 65 || //R 82 || //C 67 || //H 72 || 
		int N=sc.nextInt();
		long a[]=new long[N];
		
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		
		long past=a[0];
		
		for(int i=1;i<N;i++) {
			past=gcd(past,a[i]);
			
			
		}
		p(past);
		
	}

	

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 50732
N = int(input())
A = [[0]*10 for _ in range(10)]
ans = 0
for i in range(1, N+1):
    s = str(i)
    A[int(s[0])][int(s[-1])] += 1
for i in range(1, 10):
    for j in range(1, 10):
        ans += A[i][j]*A[j][i]
print(ans)


Measured memory_bytes: 40428
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 1e9
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mod 1000000007
#define pb push_back
#define all(s) s.begin(),s.end()
#define pie 3.14159265358979323846
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=b-1;i>=a;i--)
#define gcd __gcd
#define con continue
#define pii pair<ll,ll>

signed main(){
    ll tt=1;
    //cin>>tt;
    while(tt--){
         string s;cin>>s;
         if(s[s.size()-1]=='s')cout<<s<<"es"<<"\n";
         else cout<<s<<"s"<<"\n";
    }
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main()
{
    char a[4], b[4];
    gets(a);
    int check=strcmp(a, "ABC");
    if(check==0){
        printf("ARC\n");
        return 0;
    }
    printf("ABC\n");
    return 0;
}


Measured memory_bytes: 1524
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


vector<vector<int>>tree(100010);//tree[i][j]i番目の頂点のj番目の辺
bool checked[100010]={};
long long  node[100010]={};
long long K;
int start;

bool decide(int now,long long  now_count){
    if(checked[now])return false;
    node[now]=now_count;
    checked[now]=true;

    long long  t;
    if(now==start)t=1;
    else t=2;
    rep(i,tree[now].size()){
        if(!decide(tree[now][i],K-t))
        {
            continue;
        }
        else
        {
            t++;
        }
    }
    return true;
}

int main(){
long long N;
cin>>N;
cin>>K;
long long ans=1;
if(N==1){
    cout<<K<<endl;
    return 0;
}
int count[N+1]={};
rep(i,N-1){
int a,b;
cin>>a>>b;
tree[a].push_back(b);
tree[b].push_back(a);
count[a]++;
count[b]++;  
}

rep(i,N+1){
    if(count[i]==1)
    {
        start=i;break;
    }
}
//tree[0].push_back(100010);
decide(start,K);


for(int i=1;i<=N;i++){
    ans*=node[i];
    //cout<<node[i]<<"";
    if(ans>mod)ans%=mod;
}
//cout<<endl;
cout<<ans<<endl;
 return 0;
}
/*
4 3
1 2
2 3
3 4

6

5 4
1 2
1 3
1 4
4 5

48

16 22
12 1
3 1
4 16
7 12
6 2
2 15
5 16
14 16
10 11
3 10
3 13
8 6
16 8
9 12
4 3

271414432
*/

Measured memory_bytes: 10112
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    INF = 10 ** 18
    dp = [[INF] * N for _ in range(N)]
    for i in range(N):
        dp[i][i] = 0
    acc = [0]
    for a in A:
        acc.append(acc[-1] + a)
    for w in range(2, N+1):
        for left in range(N):
            right = left + w - 1
            if right >= N:
                continue
            wsum = acc[right + 1] - acc[left]
            for mid in range(left, right):
                dp[left][right] = min(dp[left][right], dp[left][mid] + dp[mid+1][right] + wsum)
    print(dp[0][N-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 42732
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
#define MAX 100001

vector<int> G[MAX];
int n, m;

int color[MAX];

bool dfs(int v, int c) {
  color[v] = c;
  for (int 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;
}

signed main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  fill(color, color + n + 1, 0);
  if (!dfs(1, 1)) {
    cout << n * (n - 1) / 2 - m << endl;
    return 0;
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (color[i] == 1) count++;
  }
  cout << count * (n - count) - m << endl;
  return 0;
}


Measured memory_bytes: 7424
object Main extends App{
    // Here your code !

    // 1文字ずつ分割
    val split = scala.io.StdIn.readLine().split(' ')
    val A = split(0).toString.toInt
    val B = split(1).toString.toInt
    val C = split(2).toString.toInt

    val ans = C - A + B
    if (ans > 0){
        println(C-A+B)
    }else{
        println(0)
    }
    
}

Measured memory_bytes: 25408
import java.util.Arrays;
import java.util.Scanner;

class Main {

    public static final int INF = Integer.MAX_VALUE / 4;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] red = new int[2 * N];
        int[] blue = new int[2 * N];
        Arrays.fill(red, INF);
        Arrays.fill(blue, INF);
        for (int i = 0; i < N; i++) {
            red[scanner.nextInt()] = scanner.nextInt();
        }
        for (int i = 0; i < N; i++) {
            blue[scanner.nextInt()] = scanner.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < 2 * N; i++) {
            if (blue[i] != INF) {
                int maxY = -1;
                int maxIdx = -1;
                for (int j = 0; j < i; j++) {
                    if (red[j] != INF && red[j] < blue[i] && maxY < red[j]) {
                        maxY = red[j];
                        maxIdx = j;
                    }
                }
                if (maxIdx >= 0) {
                    ans++;
                    red[maxIdx] = INF;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  string S; cin >> S;
  int N = S.length();

  bool flag = true;
  for (int i = 0; i < N; i++){
    if (S[i] != S[N - 1 - i]) flag = false;
  }

  for (int i = 0; i < N / 2; i++){
    if (S[i] != S[N / 2 - i - 1]) flag = false;
    if (S[N / 2 + i + 1] != S[N - 1 - i]) flag = false;
  }
  

  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string s;
int n,S[200010],po[200010];ll num[2019];

void solve(){
    cin >> s;
    n=s.length();
    po[0]=1;
    rep(i,n){
        po[i+1]=po[i]*10%2019;
    }
    num[0]+=1;
    rep(i,n){
        S[i+1]+=S[i]+(s[i]-'0')*po[n-1-i];
        S[i+1]%=2019;
        //cout << S[i+1] << endl;
        num[S[i+1]]+=1;
    }
    ll ans=0;
    rep(i,2019){
        ans+=num[i]*(num[i]-1)/(ll)2;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 5296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c[2][3];
    REP(i,2){
        REP(j,3){
            cin >> c[i][j];
        }
    }
    if(c[0][0]==c[1][2]&&c[0][1]==c[1][1]&&c[0][2]==c[1][0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int A[20];

int solve(int i, int m, int n){
    if ( m == 0 ) return 1;
    if ( i >= n ) return 0;
    int res = solve(i+1, m, n) || solve(i+1, m - A[i], n);
    return res;
}

int main (void) {
    int N, Q;
    int B[200];
    scanf("%d", &N);
    REP(int,i,0,N) scanf("%d", &A[i]);
    scanf("%d", &Q);
    REP(int,i,0,Q) scanf("%d", &B[i]);

    REP(int,i,0,Q){
        if ( solve( 0, B[i], N) ) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,string> P;
 
int main(){
  int n;
  while(cin>>n,n){
    map<string,int> M;
 
    P ans=P(-1,"#");
    for(int i=0;i<n;i++){
      string name;
      cin>>name;
      M[name]++;
       
      map<string,int>::iterator it=M.begin();
      vector<P> v;
      v.push_back(P(0,"$"));
      for(;it!=M.end();it++)v.push_back(P(it->second,it->first));
      sort(v.begin(),v.end(),greater<P>());
      if(v[0].first==v[1].first)continue;
      if(ans!=P(-1,"#"))continue;
      if(v[0].first>v[1].first+n-i-1)ans=P(i+1,v[0].second);
    }
 
    if(ans==P(-1,"#"))cout<<"TIE"<<endl;
    else cout<<ans.second<<" "<<ans.first<<endl;
  }
 
  return 0;
}

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

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

	int ans = 0;
	for (int i = 0; i <= 50; i++) {				//五百円
		for (int j = 0; j <= 50; j++) {			//百円
			for (int l = 0; l <= 50; l++) {		//五十円
				if (i * 500 + j * 100 + l * 50 == X && i <= A && j <= B && l <= C) {
					ans++;
				}
			}
			
		}
	}
	cout << ans << endl;
}


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

int main(void){
    // Your code here!
    int a, b, ans;
    cin >> a >> b;
    
    if (a==b){
        ans = a*2;
    } else if (a>=b) {
        ans = a * 2 -1;
    } else {
        ans = b * 2 -1;
    }
    
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define pq priority_queue
#define st first
#define nd second
#define np next_permutation

using namespace std;
typedef long long ll;
ll const inf = 1e9;
ll const mod = 1e9 + 7;

int main()
{
    int l;
    cin >> l;
    l --;
    int k;
    fr(i, 1, 20){
        if((1 << i) - 1 <= l){
            k = i - 1;
        }
    }
    int rem = l - ((1 << (k + 1)) - 1);
    int n = 20;
    int m = 19 + k + 1;

    m += __builtin_popcount(rem);
    cout << n <<' '<<m<<endl;
    int curr = (1 << (k + 1));
    while(rem > 0){
        int x = rem&-rem;
        int v = log2(x);
        v ++;
        cout << v <<' '<<n<<' '<<curr << endl;
        curr += x;

        rem -= x;

    }
    fr(i, 1, n){
        cout << i <<' '<<i + 1 <<' '<<0<<endl;
    }
    fr(i, 1, k + 2){
        cout << i <<' '<<i + 1 <<' '<<(1 << (i - 1)) << endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/


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

	int h, w;
	cin >> h >> w;
	vector<string> field(h);
	rep(i, h) cin >> field[i];

	queue<pair<int, int>> que;
	vector<vector<bool>> isDead(h, vector<bool>(w, false));
	Rep(i,1, h - 1) {
		Rep(j, 1, w - 1) {
			if (field[i][j] == '.') continue;
			if (isDead[i][j]) continue;
			int cnt = 0;
			rep(k, 8) {
				if (field[i + dy[k]][j + dx[k]] == '.')
					cnt++;
			}
			if ((field[i][j] - '0') <= cnt) {
				que.push({ i, j });
				isDead[i][j] = true;
			}
		}
	}

	int ans = 0;

	if (que.empty()) {
		cout << 0 << endl;
		return 0;
	}

	while (!que.empty()) {
		queue<pair<int, int>> next;
		ans++;
		while (!que.empty()) {
			int x = que.front().second;
			int y = que.front().first;
			que.pop();
			field[y][x] = '.';

			rep(k, 8) {
				int cnt = 0;
				if (isDead[y + dy[k]][x + dx[k]]) continue;
				if (field[y + dy[k]][x + dx[k]] != '.') {
					rep(j, 8) {
						if (field[y + dy[k] + dy[j]][x + dx[k] + dx[j]] == '.') {
							cnt++;
						}
					}
					if ((field[y + dy[k]][x + dx[k]] - '0') <= cnt) {
						next.push({ y + dy[k], x + dx[k] });
						isDead[y + dy[k]][x + dx[k]] = true;
					}
				}
			}
		}
		que = next;
	}


	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 4244
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=924844033;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cout<<setprecision(20);
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,i;cin>>n>>m;
	string str;cin>>str;
	vector<bool>ok(n,true);
	vector<vector<int>>go(n);
	vector<int>A(n);
	vector<int>B(n);
	for(i=0;i<m;i++){
		int u,v;cin>>u>>v;u--;v--;
		go[u].pub(v);
		go[v].pub(u);
		if(str[u]=='A'){A[v]++;}else{B[v]++;}
		if(str[v]=='A'){A[u]++;}else{B[u]++;}
	}
	queue<int>que;
	for(i=0;i<n;i++){
		if(A[i]==0||B[i]==0){que.push(i);ok[i]=0;}
	}
	while(que.size()>0){
		int t=que.front();que.pop();
		for(auto it:go[t]){
			if(!ok[it]){continue;}
			if(str[t]=='A'){A[it]--;}else{B[it]--;}
			if(A[it]==0||B[it]==0){que.push(it);ok[it]=0;}
		}
		
	}
	for(i=0;i<n;i++){if(ok[i]){cout<<"Yes"<<endl;return 0;}}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 12224