akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i = 0; i < n; ++i )
int main()
{
    int n,k,c;
    string s;
    cin>>n>>k>>c>>s;
    
    vector<int> l,r;
    
    int i=0;
    while(l.size()<k)
    {
        if(s[i] == 'o')
        {
            l.push_back(i);
            i +=  c+1;
        }
        else
        i++;
        
    }
    reverse(s.begin(),s.end());
    i=0;
    while(r.size()<k)
    {
        if(s[i] == 'o')
        {
            r.push_back(n-i-1);
            i += c+1;
        }
        else
        i++;
    }
    reverse(r.begin(),r.end());
    
    
   rep(i,k) if(l[i]==r[i]) printf("%d\n", l[i]+1);
}

Measured memory_bytes: 3448
import sys
input = sys.stdin.readline
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
res = 0
t = float("inf")
for i in range(N):
  if t > abs(T - 0.006 * H[i] - A):
    res = i + 1
    t = abs(T - 0.006 * H[i] - A)
print(res)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next() + sc.next();

		int n = Integer.parseInt(s);
		double sqr = Math.sqrt((double) n);
		if (Math.floor(sqr) == sqr) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> p;
int main()
{
	int n;
	while(cin>>n,n) 
	{
		priority_queue<p,vector<p>,greater<p> > q;
		int leave,arrive;
		for(int i = 0; i < n; ++i)
		{
			int h,m,s; 
			scanf(" %d:%d:%d",&h,&m,&s);
			leave=h*3600+m*60+s;
			
			scanf(" %d:%d:%d",&h,&m,&s);
			arrive=h*3600+m*60+s;
			
			q.push(p(leave,1));	
			q.push(p(arrive,-1));	
			
		}	
		int ans=0,tmp=0;
		while(!q.empty()) 
		{
			p t=q.top(); q.pop();
			if(t.second==-1) tmp--;
			else 
			{
				tmp++;
				ans=max(ans,tmp);
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}

Measured memory_bytes: 1492
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int[][] table = new int[2][1000];
		for (int i = 0; i < table.length; i++) {
			for (int j = 0; j < table[0].length; j++) {
				table[i][j] = 0;
			}
		}

		int index = 0;
		while (sc.hasNextLine() == true) {
			String line = sc.nextLine();
			
			if (line.equals("")) {
				index++;
				continue;
			}
			
			String[] nico = line.split(",");
			table[index][Integer.parseInt(nico[0]) - 1]++;
		}
		
		for (int i = 0; i < table[0].length; i++) {
			int num = 0;
			boolean flag = true;
			
			for (int j = 0; j < table.length; j++) {
				if (table[j][i] > 0) num = num + table[j][i];
				else flag = false;
			}
			
			if (flag == true) {
				System.out.println((i + 1) + " " + num);
			}
		}
	}
}

Measured memory_bytes: 26076
#include <stdio.h>
#include <math.h>

int main(void){
	int a, b, C;
	double S, L, h, d;
	
	scanf("%d %d %d", &a, &b, &C);
	
	d = (acos(-1.0)*C)/180.0;
	S = a*b*sin(d)/2.0;
	L = a + b + sqrt(a*a + b*b - 2*a*b*cos(d));
	h = b*sin(d);
	
	printf("%lf\n%lf\n%lf\n", S, L, h);
	
	return 0;
}


Measured memory_bytes: 632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        UnionFind uf = new UnionFind(nm[0]);
        for (int i = 0; i < nm[1]; i++)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            uf.TryUnite(ab[0], ab[1]);
        }
        Console.WriteLine(uf.AllRepresents.Max(uf.GetSize));
    }
}



class UnionFind
{
    public int Size { get; private set; }
    public int GroupCount { get; private set; }
    public IEnumerable<int> AllRepresents => Parent.Where((x, y) => x == y);
    int[] Sizes;
    int[] Parent;
    public UnionFind(int count)
    {
        Size = count;
        GroupCount = count;
        Parent = new int[count];
        Sizes = new int[count];
        for (int i = 0; i < count; i++) Sizes[Parent[i] = i] = 1;
    }
    public bool TryUnite(int x, int y)
    {
        int xp = Find(x);
        int yp = Find(y);
        if (yp == xp) return false;
        if (Sizes[xp] < Sizes[yp]) { var tmp = xp; xp = yp; yp = tmp; }
        GroupCount--;
        Parent[yp] = xp;
        Sizes[xp] += Sizes[yp];
        return true;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int GetSize(int x) => Sizes[Find(x)];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int Find(int x)
    {
        while (x != Parent[x]) x = (Parent[x] = Parent[Parent[x]]);
        return x;
    }
}

Measured memory_bytes: 48556
w, h, n = map(int, input().split())

left = 0
right = w
high = h
low = 0
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        left = max(left, x)
    if a == 2:
        right = min(right, x)
    if a == 3:
        low = max(low, y)
    if a == 4:
        high = min(high, y)

print(max(0, right - left) * max(0, high - low))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, K, M=1000000000;
  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A;
    K = 0;
    for(int j=0; ; j++){
      if(A%2 == 0){
        A = A/2;
        K = K + 1;
      }else{
        if(K < M){
          M = K;
        }
        break;
      }
    }
  }
  cout << M << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
        int[] A = new int[3];
	A[0]=sc.nextInt();
	A[1]=sc.nextInt();
	A[2]=sc.nextInt();
	Arrays.sort(A);
	System.out.print(A[2]-A[0]);
    }
}


Measured memory_bytes: 22356
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	if ( ch == 'A') return 1;
	else if ( ch == 'C') return 2;
	else if ( ch == 'G') return 3;
	else if ( ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum = 0, p = 1, i;
	for ( i = 0; i < strlen(str); i++ ){
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]){
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h])== 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main(void){
	int i, n;
	char str[L], com[9];
	
	for ( i = 0; i < M; i++ ) H[i][0] = '\0';
	scanf("%d", &n);
	for ( i = 0; i < n; i++ ){
		scanf("%s %s", com, str);
		if ( com[0] == 'i' ){
			insert(str);
		} else {
			if (find(str)){
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 16112
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD 1000000007ll

using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	map<string,bool> mp;
	string last="@";
	rep(i,n){
		string s;
		cin>>s;
		if (mp[s]==true || (last!="@" && last[last.size()-1]!=s[0])){
			cout<<"No"<<endl;
			return 0;
		}
		mp[s]=true;
		last=s;
	}
	cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>  
#include <stack>  
#include <queue>
#include <cmath>  
#include <vector>  
#include <cstring>  
#include<set>
#include<map>
#include<ctime>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef unsigned long long uLL;
const int M = 1005;
const int N = 1000005;
const int mod = 1000000007;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const LL lINF = 0x3f3f3f3f3f3f3f3fLL;
const int sINF = 0xcfcfcfcf;
#define ls (rt<<1)
#define rs (rt<<1|1)
int n;
int main()
{
	while (~scanf("%d", &n))
	{
		if (n < 1200)
			printf("ABC\n");
		else if (n >= 2800)
			printf("AGC\n");
		else
			printf("ARC\n");
	}
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class BPalindromePhobia {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;
        in>>s;
        int n=s.size();
        vector<int> abc(3);

        rep(i,n) {
            if(s[i]=='a') ++abc[0];
            else if(s[i]=='b') ++abc[1];
            else ++abc[2];
        }
        int m=0;
        rep(i,3){
            if(abc[i]>0) m++;
        }

        if(m<=2 && n>2){
            out<<"NO"<<endl;
            return;
        }

        if(max(abc[0],max(abc[1],abc[2]))-min(abc[0],min(abc[1],abc[2]))>1){
            out<<"NO"<<endl;
            return;
        }

        out<<"YES"<<endl;





	}
};


int main() {
	BPalindromePhobia solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

a, b, c = map(int, input().split())
"""
left = a + 2 * math.sqrt(a) * math.sqrt(b) + b
"""

if decimal.Decimal(a).sqrt() + decimal.Decimal(b).sqrt() < decimal.Decimal(c).sqrt():
    print('Yes')
else:
    print('No')



Measured memory_bytes: 59628
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    long long n, max = 0;
    
    string ans = "Yes";
    
    cin >> n;
    
    long long h[n];
    
    for (long long i=0; i<n; i++)
    {
        cin >> h[i];
        
        if (h[i] > max) max = h[i];
        if (h[i] < max - 1)
        {
            ans = "No";
            
            break;
        }
    }
    
    cout << ans << endl;
    
    
    return 0;
    
}


Measured memory_bytes: 1024
// ABC176B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	ull sum = 0;
	for (int i = 0; i < N.length(); i++) {
		sum += (N[i] - '0');
	}

	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N,T;
  cin >> N >> T;
  i64 ans = INF;

  i64 c,t;
  while(cin >> c >> t){
    if(t<=T){
      chmin(ans,c);
    }
  }

  if(ans < 10000)
    cout << ans << endl;
  else
  {
    cout << "TLE\n";
  }
  

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define endl '\n'

//Constants

//Data

//Methods

int main()
{
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0 ; i + 2 < n ; i++)
    ans += s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C';
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
    int n, m, t;
    scanf("%d%d", &n, &m);
    n = m << 1 | 1;
    if (m & 1) {
        t = 0;
        for (int i = 1; i <= m / 2; i++) {
            printf("%d %d\n", i, m - i + 1);
            t++;
        }
        for (int i = m + 1; i <= n; i++) {
            printf("%d %d\n", i, n - i + m + 1);
            t++;
            if (t == m) break;
        }
    } else {
        m++;
        t = 0;
        for (int i = 1; i <= m / 2; i++) {
            printf("%d %d\n", i, m - i + 1);
            t++;
        }
        for (int i = m + 1; i <= n; i++) {
            printf("%d %d\n", i, n - i + m + 1);
            t++;
            if (t == m - 1) break;
        }
    }
    return 0;
}


Measured memory_bytes: 3780
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int cal[100],i=0,j=0,n=0,e=0,cal1=0,oki=0,cal2=0,cal3=0;
  char k[1000];

  //入力
   while(scanf("%s",k) !=EOF )
    {
      if('0'<=k[0] && k[0]<='9')
	{
	  cal[e]=atoi(k);
	  e++;
	}
	
      else if(k[0]=='*' || k[0]=='+' || k[0]=='-' || k[0]=='/')
	{
	  cal2=cal[e-2];
	  cal3=cal[e-1];
	  if (k[0]=='*') cal[e-2]=cal2 * cal3;
	  else if(k[0]=='+')cal[e-2]=cal2 + cal3;
	  else if(k[0]=='-')cal[e-2]=cal2 - cal3;
	  else if(k[0]=='/')cal[e-2]=cal2 / cal3;
	  e--;
	}
	 

    }

  printf("%d\n",cal[e-1]);
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[110000];
int main(){
    ll n,ans=0;
    cin>>n;
    rep(i,1,n+1)cin>>a[i];
    rep(i,1,n)if(a[i]==i){swap(a[i],a[i+1]);ans++;}
    if(a[n]==n)ans++;
    cout<<ans;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

int A, B;
int Min, Max;
char s[120][120], ans[120][120];

void Init() {
	for(int i = 1; i <= 100; i++)
		for(int j = 1; j <= 100; j++)
			s[i][j] = '@';
	Min = inf; Max = 0;
	Min = min(A, B);
	Max = max(A, B);
}

void enlarge(int x, int y) {
	for(int i = 0; i < 4; i++)
		s[4 * x][4 * y - i] = 'a';
	for(int i = 0; i < 4; i++)
		s[4 * x - i][4 * y] = 'a';
	s[4 * x - 2][4 * y - 2] = 'a';
}

void get() {
	int num = 0;
	bool f = 1;
	if(Min > 1) {
		for(int R = 1; R <= 20; R++) {
			f = 1;
			for(int C = 1; C <= 25; C++) {
				num++;
				if(num > (Min - 1)) {
					f = 0;
					break;
				}
				enlarge(R, C);
			}
			if(f == 0) break;
		}
	}
	int all = Max - Min;
	if(Min == 1) all++;
	int cnt = 0;
	for(int R = 100; R >= 79; R--) {
		f = 1;
		for(int C = 100 - R + 1; C <= 95; C += 3) {
			cnt++;
			if(cnt > all) {
				f = 0;
				break;
			}
			s[R][C] = 'a';
			//if(R & 1) s[R][2 * C] = 'a';
			//else s[R][2 * C - 1] = 'a';
		}
		if(f == 0) break;
	}
}

void solve() {
	get();
	if(A <= B) {
		for(int i = 1; i <= 100; i++) {
			for(int j = 1; j <= 100; j++) {
				if(s[i][j] == 'a') ans[i][j] = '#';
				else ans[i][j] = '.';
			}
		}
	}
	else {
		for(int i = 1; i <= 100; i++) {
			for(int j = 1; j <= 100; j++) {
				if(s[i][j] == 'a') ans[i][j] = '.';
				else ans[i][j] = '#';
			}
		}
	}
}

int main()
{
	while(scanf("%d %d", &A, &B) != EOF)
	{
		Init();
		solve();
		printf("100 100\n");
		for(int i = 1; i <= 100; i++) {
			for(int j = 1; j <= 100; j++)
				printf("%c", ans[i][j]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int gcd(int a,int b){
   if(b > a) swap(a , b);
   int tem;
  while(b != 0){
    tem = a % b;
    a = b;
    b = tem;
  }
  return a;
 }
int main() {
  long long n;
  cin >> n;
  long long A[n + 10];
  int ans;
  cin >> ans;
  for(int i=1; i<n; i++){
    cin >> A[i];
    ans = gcd(ans , A[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
using namespace std;
string a, b, c;
int main()
{
    int i, j, k;
    char x = 'a';
    cin >> a >> b >> c;
    i = j = k = 0;
    while(1) {
        if(x == 'a') {
            if(i == a.size()){
                cout << 'A';
                break;
            }
            x = a[i];
            i++;
        }else if(x == 'b'){
            if(j == b.size()){
                cout << 'B';
                break;
            }
            x = b[j];
            j++;
        }else{
            if(k == c.size()){
                cout << 'C';
                break;
            }
            x = c[k];
            k++;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define int long long
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	int c = b;
	for (int d = 1; d < a; d++) {
		c *= (b - 1);
	}
	cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}
#define dbg(x) cout <<#x<<":"<<x<<endl;
 
#define int ll

signed main() {
	fast;

	int n,k;
	cin>>n>>k;

	if(2*k-1>n) {
		cout<<-1;
		return 0;
	}

	set<int> st[3];
	for(int i=0;i<2;i++)
		for(int j=k+i*k;j<k+i*k+n;j++) st[i].insert(j);

	vector<pair<pii,int>> ans(n);
	for(int i=0;i<n;i++) ans[i].s = k + 2*n + i;

	int j = n-1;
	for(int i=k+2*n-1;i>=(k+2*n)-(2*k-1);i-=2,j--){
		// cout<<"#"<<i<<endl;
		ans[j].f.s = i;
		ans[j].f.f = ans[j].s - ans[j].f.s;
	}
	for(int i=k+2*n-2;i>=(k+2*n)-(2*k-1);i-=2,j--) {
		// cout<<"$"<<i<<endl;
		ans[j].f.s = i;
		ans[j].f.f = ans[j].s - ans[j].f.s;
	}
	for(int i=(k+2*n)-(2*k-1)-1;i>=k+n;i--,j--) {
		ans[j].f.s = i;
	}

	for(int i=1;i<=n-(2*k-1);i++) {
		ans[i-1].f = {k+i-1,k+i-1+n};
	}

	for(int i=0;i<n;i++) cout<<ans[i].f.f<<" "<<ans[i].f.s<<" "<<ans[i].s<<endl;

}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    if (S[0]=='R' && S[1] == 'R' && S[2] == 'R') cout << 3 << "\n";
    else if ((S[0]=='R' && S[1] =='R' && S[2] == 'S')||(S[0]=='S' && S[1] == 'R'&& S[2] == 'R')) cout << 2 << "\n";
    else if (S[0] == 'S' && S[1] == 'S' && S[2] == 'S') cout << 0 <<"\n";
    else cout << 1 << "\n";
}

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

int main() {
    int W, H, X, Y, R;
    cin >> W >> H >> X >> Y >> R;
    if (0 <= X - R && X + R <= W) {
        if (0 <= Y - R && Y + R <= H) {
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 3116
n = int(input())
as_ = list(map(int, input().strip().split()))

cum_alt_sum = [0] * n
for i in range(n):
    if i == 0:
        prev = 0
    else:
        prev = cum_alt_sum[i - 1]
    if i % 2 == 0:
        cum_alt_sum[i] = prev + as_[i]
    else:
        cum_alt_sum[i] = prev - as_[i]

ans = [0] * n
for i in range(n):
    if i == 0:
        ans[i] = cum_alt_sum[-1]
    else:
        ans[i] = - cum_alt_sum[i - 1] + (cum_alt_sum[-1] - cum_alt_sum[i - 1])
        if i % 2 == 1:
            ans[i] *= -1


print(' '.join(map(str, ans)))


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;
using ll=long long;


int c[10][1005];

int main() {
  int h,w,k;cin >> h >> w >> k;
  int ans=100100100;
  vector<string> st(h);
  rep(i,h)cin >> st[i];
  rep(tmp,1<<(h-1)){
    int g=0;
    vector<int> id(h);
    rep(i,h){
      id[i]=g;
      if(tmp>>i&1) g++;
    }
    g++;

    rep(i,g)rep(j,w)c[i][j]=0;
    rep(i,h)rep(j,w)c[id[i]][j]+=(st[i][j]-'0');
    bool ok = true;
    rep(i,g)rep(j,w)if(c[i][j]>k)ok=false;
    if(!ok)continue;

    int count=g-1;
    vector<int> now(g);
    auto add =[&](int j){
      rep(i,g)now[i]+=c[i][j];
      rep(i,g)if(now[i]>k)return false;
      return true;
    };
    rep(j,w){
      if(!add(j)){
        count++;
        now = vector<int>(g);
        add(j);
      }
    }
    ans=min(ans,count);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

ll solve(vector<ll> &A, vector<ll> &B) {
    ll count = 0;

    for (int i = 0; i < (int) B.size(); i++) {
        for (int j = 0; j < 2; j++) {
            if (A[i + j] > 0) {
                int diff = min(A[i + j], B[i]);
                B[i] -= diff;
                A[i + j] -= diff;
                count += diff;
            }
        }
    }

    return count;
}

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

    vector<ll> A(N + 1);
    for (int i = 0;  i < N + 1; i++) {
        cin >> A[i];
    }

    vector<ll> B(N);
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    cout << solve(A, B) << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
int N;

void solve() {
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];
    for (int i = 0; i < N; ++i) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    vector<ll> S(N + 1);
    S[0] = 0;
    for (int i = 0; i < N; ++i) {
        int j = N - 1 - i;
        int index = distance(C.begin(), lower_bound(C.begin(), C.end(), B[j] + 1));
        S[i + 1] = S[i] + (N - index);
    }

    ll ans = 0;
    for(int i = 0; i < N; ++i)
    {
        int index = distance(B.begin(), lower_bound(B.begin(), B.end(), A[i] + 1));
        ans += S[N - index];
    }
    cout << ans << endl;
}

int main() {
    solve();
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


int res[3000005];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    ff(x,1,100){
        ff(y,1,100){
            ff(z,1,100){
                res[x*x + y*y + z*z + z*x + z*y + x*y]++;
            }
        }
    }
    int n;
    cin >> n;
    ff(i,1,n)cout << res[i] << "\n";
    return 0;
}


Measured memory_bytes: 3896
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;



ll solve(void);
ll gcd(ll x, ll y);

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

ll mulmod(ll x, ll y)
{
	return (x * y) % mod;
}

ll submod(ll x, ll y)
{
	return (x - y + 100 * mod) % mod;
}

ll power(ll n, ll r)
{
	if ( r == 0 ) { return 1; }
	if ( r == 1 ) { return n; }
	if ( n == 0 ) { return 0; }
	if ( n == 1 ) { return 1; }

	if (r % 2 == 0)
	{
		ll y = power(n, r/2);
		return mulmod(y, y);
	}
	else
	{
		ll y = power(n, (r-1)/2);
		return n * mulmod(y, y) % mod;
	}
}

ll gcd(ll x, ll y)
{
	if (y == 1) { return 1;}
	if (x % y == 0) { return y; }
	return gcd(y, x % y);
}

vector<ll> perm;
vector<ll> inv;
void init_inv(ll m)
{
	perm.resize(m);
	inv.resize(m);
	
	perm[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i < m; i++)
	{
		perm[i] = mulmod(perm[i-1], i);
	}
	
	for (ll i = 1; i < m; i++)
	{
		inv[i] = power(perm[i], mod - 2);
	}
}

ll ncr(ll n, ll r)
{
	// n (n-1) ... (n-r)
	if ( r == n || r == 0 ) { return 1; }

	ll ans = 1;
	//for (ll i = 0; i < r; i++)
	//	ans = mulmod(ans, n - i);

	// return mulmod(ans, inv[r]);
	return mulmod(perm[n], mulmod(inv[n-r], inv[r]));
}

ll solve(void)
{
	ll n, k;
	cin >> n >> k;

	vector<ll> P(n), S(n+1, 0);

	for (auto&p : P)
	{
		cin >> p;
	}

	for (ll i = 0; i + 1 <= n; i++)
	{
		S[i+1] = S[i] + P[i] + 1;
	}

	ll ans = 0;
	for (ll i = 0; i + k <= n; i++)
	{
		ans = max(S[i+k]-S[i], ans);
	}

	printf("%.8Lf\n", (ld)ans / 2.0);

	return 0;
}



Measured memory_bytes: 3328
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     FAST        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     int 	    long long
#define 	pb 	        push_back
#define     pp          pop_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%lld",&i)
#define     scann(i,j)  scanf("%lld%lld",&i,&j)
#define     print(i)    printf("%lld\n",i)
#define     printt(i,j) printf("%lld %lld\n",i,j)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define     loopp(i,n) 	for(int i = 1 ; i <n ; i++)
#define     rep(i,n)    for(int i=n-1;i>=0;i--)
#define     rev(v)      reverse(v.begin(),v.end())
#define     reset(a,b)  memset(a,b,sizeof(a))
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::reverse_iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define     sorted(v)   is_sorted(v.begin(),v.end())
#define 	mapp 	    map<int,int>
#define     rmap        map<int,int,greater<>>m
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>
#define     rset        set<int,greater<>>s
#define 	set_it 	    set<int>::reverse_iterator si
#define     map_it      map<int,int> :: reverse_iterator mi
#define     digit(n)    floor(log10(n)+1)
#define 	yes 	    cout<<"YES"<<endl
#define 	no 	        cout<<"NO"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          INT_MAX
#define     lmx         LLONG_MAX
#define     mn          INT_MIN
#define     lmn         LLONG_MIN
#define     inf         0x3f3f3f3f
#define     inff        10e18
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
   // freopen ("(input).txt" , "r",  stdin) ;
    string st,stt;
    int low=0,high=0;
    int l,r; char ch;
    int n,k,t,x,y,z,d=0,cnt=0,temp=0,sum=0,f=0,flag=0;
    cin>>n ; vect v ,a ; sett s ; mapp m ; pairr p ;
    sum+=n-1;
    for(int i=2;i<n;i++)
    {
        if(n%i==0)
            sum+=n/i-1;
        else
            sum+=n/i;
    }
    cout<<sum<<endl;

}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}





Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	string S;
	int w;
	cin >> S >> w;

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

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
num =int(input())
value = list(map(int, input().split()))
value.sort()
if num == 2:
  answer = value[1]
else:
  cnt = 0
  for i in range(0, num):
      if value[i]%(value[1])!=0:
        cnt += 1
        if cnt == 2:
          break
  if cnt == 1:
    answer = value[1]
  elif cnt == 0:
    answer = value[0]
  else:
    for i in range (0, value[0]):
      cnt = 0
      for j in range(0, num):
        if value[j]%(value[0]-i)!=0:
          cnt += 1
          if cnt == 2:
            break
      if cnt == 1 or cnt == 0:
        answer = value[0] - i
        break
print(answer)

Measured memory_bytes: 14436
#include <stdio.h>
#define MAX 100
#define INFTY 200000
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int n,a[MAX][MAX];
 
void dijkstra(){
    int minv,i,v,u;
    int d[MAX],color[MAX];
 
    for(i=0;i<n;i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
 
    d[0] = 0;
    color[0] = GRAY;
    while(1){
        minv = INFTY;
        u = -1;
        for(i = 0;i<n;i++){
            if(minv>d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1)break;
        color[u] = BLACK;
        for(v = 0;v<n;v++){
            if(color[v] != BLACK && a[u][v] != INFTY){
                if(d[v]>d[u]+a[u][v]){
                    d[v] = d[u] + a[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(i = 0;i<n;i++){
        printf("%d",i);
        printf(" ");
        d[i]= (d[i] == INFTY) ? -1 : d[i];
         printf("%d\n",d[i]);
    }
}
 
int main(){
    int i,k,c,u,v,j;
 
    scanf("%d",&n);
    for(i = 0;i<n;i++){
        for(j = 0;j<n;j++){
            a[i][j] = INFTY;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(j = 0;j<k;j++){
            scanf("%d %d",&v,&c);
            a[u][v] = c;
        }
    }
    dijkstra();
 
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
  int n;
  double sum=0.0;
  double x[10]={0.0};
  char u[10];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lf",&x[i]);
    scanf("%s",&u[i]);
    if(u[i]=='J'){
      sum=sum+x[i];
    } else {
      sum=sum+x[i]*380000.0;
    }
  }
  
  printf("%f\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
struct P {int x,y,z;};

class RMQ{
public:
  int n,dat[1000010];
  void init(int _n){
    n=1;
    while(n<_n)n*=2;
    fill(dat,dat+2*n-1,MAX);
  }
  void update(int k,int a){
    k+=n-1;dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b){return query(a,b,0,0,n);}
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return MAX;
    if(a<=l&&r<=b) return dat[k];
    else {
      int vl=query(a,b,k*2+1,l,(l+r)/2);
      int vr=query(a,b,k*2+2,(l+r)/2,r);
      return min(vl,vr);
    }
  }
};

class RMQ2{
public:
  int n,dat[1000010];
  void init(int _n){
    n=1;
    while(n<_n)n*=2;
    fill(dat,dat+2*n-1,-1);
  }
  void update(int k,int a){
    k+=n-1;dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b){return query(a,b,0,0,n);}
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return -1;
    if(a<=l&&r<=b) return dat[k];
    else {
      int vl=query(a,b,k*2+1,l,(l+r)/2);
      int vr=query(a,b,k*2+2,(l+r)/2,r);
      return max(vl,vr);
    }
  }
};

RMQ x,y;
RMQ2 x2,y2;

void Main() {
  int n,d;
  cin >> n >> d;
  P a[n];
  vector<int> v;
  rep(i,n) {
    int x,y,z;
    cin >> x >> y >> z;
    a[i]=(P){x,y,z};
    v.pb(z);
  }
  sort(all(v));
  v.erase(unique(all(v)),v.end());
  map<int,int> m;
  rep(i,v.size()) m[v[i]]=i;
  x.init(v.size());
  y.init(v.size());
  x2.init(v.size());
  y2.init(v.size());
  rep(i,n) {
    int r=m[a[i].z];
    x.update(r,min(x.query(r,r+1),a[i].x));
    y.update(r,min(y.query(r,r+1),a[i].y));
    x2.update(r,max(x2.query(r,r+1),a[i].x));
    y2.update(r,max(y2.query(r,r+1),a[i].y));
  }
  ll ans=0,r=0;
  rep(l,v.size()) {
    while(r<v.size()&&v[r]-v[l]<=d) r++;
    ans=max(ans,(ll)(x2.query(l,r)-x.query(l,r))*(ll)(y2.query(l,r)-y.query(l,r)));
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 28028
use proconio::input;
use std::cmp::{max, min};

const MAX_L: u32 = 100_000;
const BASE_SIZE: usize = 1 << 10;

fn main() {
    input! {
        n: usize,
        vw: [(u32, usize); n],
        q: usize,
        vl: [(usize, usize); q],
    }
    let dp = make_dp(&vw);
    for vlq in vl {
        println!("{}", calc(&vw, vlq.0 - 1, vlq.1, &dp));
    }
}

fn make_dp(vw: &Vec<(u32, usize)>) -> Vec<Vec<u32>> {
    let mut dp = Vec::<Vec<u32>>::new();

    dp.push(
        (0..=MAX_L)
        .map(|i| if i < vw[0].1 as u32 { 0 } else { vw[0].0 })
        .collect()
    );

    let n = min(vw.len(), BASE_SIZE - 1);
    for c in 1..n {
        let p = (c - 1) / 2;
        dp.push(
            (0..=MAX_L)
            .map(|i| {
                let w = vw[c].1;
                let v = if i < w as u32 { 0 } else { dp[p][i as usize - w] + vw[c].0 };
                max(dp[p][i as usize], v)
            })
            .collect()
        );
    }

    dp
}

fn calc(
    vw: &Vec<(u32, usize)>,
    u: usize, 
    l: usize,
    dp: &Vec<Vec<u32>>
) -> u32 {
    if u < dp.len() {
        dp[u][l]
    } else {
        let p = (u - 1) / 2;
        let w = vw[u].1;
        let pv1 = calc(vw, p, l, dp);
        let pv2 = if l < w { 0 } else { calc(vw, p, l - w, dp) + vw[u].0 };
        max(pv1, pv2)
    }
}


Measured memory_bytes: 413020
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int> ac_num(n);
	ac_num[0] = 0;
	for (int i = 1; i < n; i++) {
		ac_num[i] = ac_num[i - 1];
		if (s[i] == 'C' && s[i - 1] == 'A') {
			ac_num[i]++;
		}
	}
	vector<int> ans(q);
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		ans[i] = ac_num[r-1] - ac_num[l-1];
	}
	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

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

typedef long long ll;
#define lowbit(x) (x&-x)

const int maxn = 200001;
int n;
ll h[maxn];
ll a[maxn];
ll dp[maxn];
ll bit[maxn];

ll query(ll x) {
    ll res = 0;
    for (; x; x -= lowbit(x)) {
        res = max(bit[x], res);
    }
    return res;
}

void update(ll x, ll y) {
    for (; x <= n; x += lowbit(x)) {
        bit[x] = max(bit[x], y);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        dp[i] = query(h[i]) + a[i];
        update(h[i], dp[i]);
    }

    cout << query(n) << endl;

    return 0;
}



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


int main() {
    int N; cin >> N;
    vector<string> V(N);
    for(int i=0;i<N;i++){
        cin >> V.at(i);
    }
    sort(V.begin(),V.end());

    int ans=0;
    string x="";
    for(int i=0;i<N;i++){
        if(x!=V.at(i)){
            ans++;
            x=V.at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9600
#include<stdio.h>
#include<string.h>
#define MAX 30

struct NODE { int parent, left, right; };
struct NODE BTree[MAX];

int Degree(int id) {
	if (BTree[id].left != -1 && BTree[id].right != -1)
		return 2;
	else if (BTree[id].left == -1 && BTree[id].right != -1)
		return 1;
	else if (BTree[id].left != -1 && BTree[id].right == -1)
		return 1;
	else return 0;
}

int Sibling(int id) {
	if (BTree[id].parent == -1) {
		return -1;
	}
	else if (BTree[BTree[id].parent].left == id) {
		return BTree[BTree[id].parent].right;
	}
	else return BTree[BTree[id].parent].left;
}


int Dep(int id) {
	int cnt = -1;
	while (id != -1) {
		id = BTree[id].parent;
		cnt++;
	}
	return cnt;
}

int Height(int id) {
	if (BTree[id].left == -1 && BTree[id].right == -1)
		return 0;
	else if (BTree[id].left == -1 && BTree[id].right != -1)
		return Height(BTree[id].right) + 1;
	else if (BTree[id].left != -1 && BTree[id].right == -1)
		return Height(BTree[id].left) + 1;
	else if (BTree[id].left != -1 && BTree[id].right != -1) {
		if (Height(BTree[id].right) >= Height(BTree[id].left))
			return Height(BTree[id].right) + 1;
		else return Height(BTree[id].left) + 1;
	}
}


int main() {
	int N;
	int num, l, r;
	char type[30];
	for (int i = 0; i < MAX; i++) {
		BTree[i].parent = -1;
		BTree[i].left = -1;
		BTree[i].right = -1;
	}
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d %d %d", &num, &l, &r);
		if (l != -1) {
			BTree[num].left = l;
			BTree[l].parent = num;
		}
		if (r != -1) {
			BTree[num].right = r;
			BTree[r].parent = num;
		}
	}

	for (int i = 0; i < N; i++) {
		if (BTree[i].parent == -1)strcpy(type,"root");
		else if (BTree[i].left == -1 && BTree[i].right == -1)strcpy(type, "leaf");
		else strcpy(type, "internal node");
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, BTree[i].parent, Sibling(i), Degree(i), Dep(i), Height(i),type);
	}

	return 0;
}



Measured memory_bytes: 2104
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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


int main(void) {
	int n;
	int maxi = -1;
	int total = 0;
	int m;

	cin >> n;
	vector<int> t(n);
	FOR(i, 0, n - 1) {
		cin >> t[i];
		total += t[i];
	}
	cin >> m;
	vector<int> p(m), x(m);
	FOR(i, 0, m - 1) {
		cin >> p[i] >> x[i];
	}

	FOR(i, 0, m - 1) {
		cout << total - t[p[i] - 1] + x[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int INF = INT_MAX / 2;

int main()
{
    int s, t, u, n, o, d;
    cin >> s >> t >> u >> n >> o >> d;

    vector<vector<int> > trainingDp(u+1, vector<int>(s+1, -INF));
    trainingDp[0][0] = 0;
    while(--t >= 0){
        int e, c;
        cin >> e >> c;
        for(int i=u-1; i>=0; --i){
            for(int j=0; j+e<=s; ++j){
                trainingDp[i+1][j+e] = max(trainingDp[i+1][j+e], trainingDp[i][j] + c);
            }
        }
    }

    vector<int> donutDp(10000+1, 0);
    while(--n >= 0){
        int h, a;
        cin >> h >> a;
        for(int i=0; i+a<=10000; ++i){
            donutDp[i+a] = max(donutDp[i+a], donutDp[i] + h);
        }
    }

    vector<int> dp(s+1, -INF);
    dp[s] = 0;
    while(--d >= 0){
        vector<int> nextDp(s+1, -INF);
        for(int i=0; i<=s; ++i){
            for(int j=0; j<=i; ++j){
                if(trainingDp[u][j] >= 0)
                    nextDp[min(s, i-j+o)] = max(nextDp[min(s, i-j+o)], dp[i] + donutDp[trainingDp[u][j]]);
            }
        }
        dp.swap(nextDp);
    }

    int ret = *max_element(dp.begin(), dp.end());
    cout << max(ret, -1) << endl;

    return 0;
}

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

#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define REP(i,k,N) for(int i=k;i<(int)(N);i++)

using namespace std;
int main(){
    int N,M;
    while(cin >> N >> M,N) {
        int t[1000], n[1000], m[1000], s[1000];
        int r, q, begin, end, id;
        cin >> r;
        rep(i, r) cin >> t[i] >> n[i] >> m[i] >> s[i];
        cin >> q;
        rep(i, q) {
            cin >> begin >> end >> id;
            //ここまで入力

            int ans = 0,  pc= 0, B;
            rep(j, r) {
                if (m[j] != id)continue;
                if (s[j] == 1) {
                    //ログイン
                    pc++;
                    if (pc == 1) B = t[j];
                }else{
                    //ログアウト
                    pc--;
                    if (pc == 0 && begin <= t[j] && B <= end) {
                        ans += (min(end, t[j]) - max(begin, B));
                    }
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3012
N = int(input())
A = list(map(int, input().split()))
B = [0]*(N+1)
for n in range(N):
  B[N-n]=(sum(B[::N-n])%2+A[N-n-1])%2
print(sum(B),'\n',*(i for i, x in enumerate(B) if x))

Measured memory_bytes: 13112
#include <stdio.h>
int main(){
	char s[2056]="\0";
	int i=0;
	gets(s);
	for(i=0;i<2056;i++){
		if(s[i]=='\0')	break;
		if('a'<=s[i]&&s[i]<='z'){
			s[i]='A'+(s[i]-'a');
		}
	}
	puts(s);
	return 0;
}

Measured memory_bytes: 524
#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>;

int main(){
  int n;
  cin >> n;
  rep(i,n){
    rep(j,n){
      if(n == 4*i + 7*j){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    bool ans = true;
    if (S.size() % 2 == 1) {
        ans = false;
    }
    else {
        while(S.size() > 0) {
            if (S.at(0) == 'h' && S.at(1) == 'i') {

            }
            else {
                ans = false;
            }
            S.erase(0,2);
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		System.out.println((sc.nextInt() - 1) * (sc.nextInt() - 1));
	}
}

Measured memory_bytes: 21972
N = int(input())
a = [-1]
for i in range(N):
    a_i = int(input())
    a.append(a_i)

i = 1
already_pressed = set([i])
for count in range(1,N+1):
    i=a[i]
    if i in already_pressed:
        print(-1)
        exit()
    if i==2:
        print(count)
        exit()
    already_pressed.add(i)

Measured memory_bytes: 13216
def lr(c):
    # left return 0, right return 1
    if (
        c == "p"
        or c == "l"
        or c == "o"
        or c == "k"
        or c == "m"
        or c == "i"
        or c == "j"
        or c == "n"
        or c == "u"
        or c == "y"
        or c == "h"
    ):
        return 1
    else:
        return 0


while True:
    S = input()
    change = 0
    if S == "#":
        break
    maenote = lr(S[0])
    for i in range(1, len(S)):
        if not maenote == lr(S[i]):
            change += 1
        maenote = lr(S[i])
    print(change)


Measured memory_bytes: 5568
#include <stdio.h>
#define N 10000

int Linearsearch(int x[],int n,int key){
  int i=0;
  x[n] = key;
  while(x[i] != key) i++;
  return  i != n;
}

int main(){
  int i,n,x[N+1],q,key,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)  scanf("%d",&x[i]);
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(Linearsearch(x,n,key)) count++;
  }

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



Measured memory_bytes: 2144