akhauriyash/Code-Regression huggingface dataset:
import sys
n, m = map(int, input().split())
keys = []
box = [[] for _ in range(n+1)]

dr = 2**n
dp = [-1] * dr
dp[0] = 0

for i in range(m):
    a, b = map(int, sys.stdin.readline().split())
    c = list(map(int, sys.stdin.readline().split()))
    k = 0
    for box in c:
        k += 1 << box-1
    for j in range(dr):
        if dp[j] != -1:
            price = dp[j] + a
            nex = j | k
            if dp [nex] == -1 or dp[nex] > price:
                dp[nex] = price

print(dp[dr-1])

Measured memory_bytes: 42860
#include<stdio.h>
 
#define MAXLEN 20000
 
int garea,gareas[(MAXLEN/2)+1],gcnt;
 
 
int getArea( char *inputs, int start, int end )
{
    int i;
    int ravine,water;
    
    gareas[gcnt]=water=ravine=0;
    for( i=start; i<=end && '\0'!=*(inputs+i) ; i++ ) {
        if( '\\'== *(inputs+i) ) {
            water+=(ravine*2);
            ravine++;
            water++;
        } else if( 0 < ravine && '/' == *(inputs+i) ) {   
            ravine--;
            if( 0 == ravine ) {
                gareas[gcnt]+=water;
                break;
            }           
        } else {
	     	gareas[gcnt]+=ravine;
        }       
    }
 
    return gareas[gcnt];
}
  
int checkRavine( char *inputs, int start )
{
    int i,j;
    int ravine;
    
    ravine=0;
    for( i=start, j=0; '\0'!=*(inputs+i) && j<MAXLEN; i++, j++ ) {
        if( '\\'== *(inputs+i) ) {
            ravine++;
        } else if( 0 < ravine && '/' == *(inputs+i) ) {   
            ravine--;
            if( 0 == ravine ) {
            	garea+=getArea( inputs, start, i );
            	gcnt++;
                return j;
            }           
        }
    }
    return 0;
}
 
 
void getAreas( char *inputs )
{
    int i,next;
     
    next=0;
    for( i=0; '\0'!=inputs[i]; i++ ) {
        next=checkRavine( inputs, i );
        i+=next;
    }
 
    return;
}
 
int main( void ) 
{
    char inputs[MAXLEN+1];
    int i;
 
    scanf( "%s", inputs );
    garea=gcnt=0;
    getAreas( inputs );
     
    printf( "%d\n", garea );
    
    if( gcnt ) {
        printf( "%d ", gcnt );
        gcnt--;
        for( i=0; i<=gcnt; i++ ) {
            printf( "%d", gareas[i] );
            if( i < gcnt ) {
                printf( " " );  
            } else {
            	printf( "\n" ); 
            }
        }
    } else {
        printf( "0\n" );
    }
     
    return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int		a[200001], b[200001] = {0};

int main()
{
	int		c,i,j,k,n,x,y,ans = 0;
	int		m = 0;
	
	scanf("%d", &n);
	for(i=1;i<=n;i++) scanf("%d", &a[i]);

	for(i=n;i>=1;i--) {
		x = n/i;
		if (x == 1) {
			b[i] = a[i];
		} else {
			y = 0;
			for(j=x;j>=2;j--) {
				y += b[i*j];
			}
			y = y % 2;
			if (a[i] == y) b[i] = 0;
			else b[i] = 1;
		}
		if (b[i]) m++;
	}

	printf("%d\n",m);
	x = 0;
	for(i=1;i<=n;i++) {
		if (b[i]) {
			if (x) printf(" ");
			printf("%d",i);
			x = 1;
		}
	}
	if (x) ENTER;
	
	return 0;
}


Measured memory_bytes: 2432
#include<stdio.h>
#define MAX 2000000

int H,A[MAX+1];

void swap(int *a,int *a_max){
  int temp;
  temp=*a;
  *a=*a_max;
  *a_max=temp;
}

void maxHeapify(int i){
  int l,r,largest;
  l=i*2;
  r=i*2+1;

  if(l<=H &&A[l]>A[i])largest=l;
  else largest=i;
  if(r<=H && A[r]>A[largest])largest=r;

  if(largest!=i){
    swap(&A[i],&A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);

  for(i=H/2;i>=1;i--)maxHeapify(i);

  for(i=1;i<=H;i++)printf(" %d",A[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    if(A%3==0||B%3==0||(A+B)%3==0){cout<<"Possible"<<endl;}
    else{cout<<"Impossible"<<endl;}
    return 0; 
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

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

		int n = stdIn.nextInt();

		List<Town> townList = new ArrayList<Town>();
		IntStream.range(0, n).forEach(i -> townList.add(new Town(stdIn.nextInt(), stdIn.nextInt())));

		Field field = new Field(townList);
		System.out.println(field.average());

		stdIn.close();
	}
}

class Field {
	private List<Town> townList;
	private List<Path> allPaths;

	public Field(List<Town> townList) {
		this.townList = townList;
		this.allPaths = new ArrayList<>();
		permutation(new Path());
	}

	public double average() {
		double sum = 0;

		for (Path path : allPaths) {
			for (int i = 0; i < path.size(); i++) {
				Town current = townList.get(path.getCurrent(i)-1);
				Town next = townList.get(path.getNext(i)-1);

				sum += Town.getDistance(current, next);
			}
		}

		return sum / allPaths.size();
	}

	private void permutation(Path target) {

		int size = target.size();

		if (size == townList.size()) {
			allPaths.add(target);
			return;
		}

		for (int i = 0; i <= size; i++) {
			Path nextpath = (Path) target.clone();
			nextpath.add(i, size + 1);
			permutation(nextpath);

		}
	}

	public List<Town> getTownList() {
		return townList;
	}

	public List<Path> getAllPaths() {
		return allPaths;
	}

}

class Path extends ArrayList<Integer> {

	public int getCurrent(int index) {
		return get(index);
	}

	public int getNext(int index) {

		if (index == this.size() - 1) {
			return get(index);
		}

		return get(index + 1);
	}

}

class Town {
	private int x;
	private int y;

	public Town(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public static double getDistance(Town former, Town latter) {
		return Math.sqrt((former.x - latter.x) * (former.x - latter.x) + (former.y - latter.y) * (former.y - latter.y));
	}

	@Override
	public String toString() {
		return "Town [x=" + x + ", y=" + y + "]";
	}

}


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

int N;
int A[2000000];

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

	sort(A,A+N);
	for(int i = 1; i < N; i++){
		if(A[i] == A[i-1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1024
//
//  main.cpp
//  Hello
//
//  Created by Gasser Mamdouh on 29/10/2019.
//  Copyright © 2019 Gasser Mamdouh. All rights reserved.
//

#include <iostream>
#include <map>
#include <utility>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <string.h>
#include <list>
#include <set>
#include <stdio.h>
#include <numeric>
#include <queue>
#include <memory>
#include <limits>
#include <iomanip>

using namespace std;

int getMax(const vector<int> &vec, const int &excludeIndex){
    int mx = -1;
    for(int i = 0; i < 3; i++){
        if(i == excludeIndex){
            continue;
        }
        mx = max(mx, vec[i]);
    }
    
    return mx;
    
}

int main(){
    int n;
    cin >> n;
    vector<vector<int> > vec(n, vector<int> (3)), dp(n, vector<int> (3));
    for(int i = 0; i < n; i++){
        cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
    }
    dp[0][0] = vec[0][0];
    dp[0][1] = vec[0][1];
    dp[0][2] = vec[0][2];
    for(int i = 1;i < n; i++){
        for(int j = 0; j < 3; j++){
            dp[i][j] = getMax(dp[i - 1], j) + vec[i][j];
        }
    }
    
    cout << getMax(dp[n - 1], -1) << endl;
    return 0;
}


Measured memory_bytes: 11136
import math

def distance(point1, point2):
  return math.sqrt((point1[0]-point2[0])**2 + (point1[1]-point2[1])**2)

N = int(input())
x_y_list = []
for i in range(0, N):
  x, y = input().split(" ")
  x, y = int(x), int(y)
  x_y_list.append((x, y))

sum = 0
fact = math.factorial(N-1)
for i in range(0, N):
  for j in range(0, N):
    if i == j:
      continue
    else:
      sum += distance(x_y_list[i], x_y_list[j]) * fact

print(sum/(math.factorial(N)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define w(x) int x;cin>>x;while(x--)
#define ll long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define vi vector<int>
#define ff first
#define ss second
#define fr(a,b) for(int i=a;i<=b;i++)
#define inf 1e18
#define mod 998244353
int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    ll k=t*s;
    if(k>=d)
    cout<<"Yes\n";
    else
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int answer;
void check(int sum, int limit, int i, int n, int time);

int main(void) {
    while(1) {
        int limit, n;
        scanf("%d %d", &limit, &n);
        if(n == 0 && limit == 0) break;
        for(int i = 1; i <= limit; i++) {
            check(0, limit, i, n, 0);
        }
        printf("%d\n", answer);
        answer = 0;
    }
}

void check(int sum, int limit, int i, int n, int time) {
    sum += i;
    time++;

    if(time == 3) {
        if(sum == n) {
            answer++;
        }
    } else {
        for(int j = i + 1; j <= limit; j++) {
            check(sum, limit, j, n, time);
        }
    }
}



Measured memory_bytes: 2108
#include <cstdio>
#include <cstring>

int main()
{
  char o[51], e[51];
  scanf("%s %s", o, e);
  char *po = o;
  char *pe = e;
  for (; *pe != 0; ++po, ++pe)
  {
    printf("%c%c", *po, *pe);
  }
  if (*po != 0)
  {
    printf("%c", *po);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define TYPE int
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }

int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	int *H = (int *)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &H[i]);
	}

	qsort(H, N, sizeof(TYPE), cmp);
	//for (int i = 0; i < N; i++)
	//{
	//	printf("%d ", H[i]);
	//}
	long long dif;
	long long mindif = 10000000000;
	long long ans;
	for (int i = 0; i + K - 1 < N; i++)
	{
		dif = H[i + K - 1] - H[i];
		if (dif < mindif) {
			mindif = dif;
		}
	}
	ans = mindif;
	printf("%lld\n", ans);
	return 0;
}

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

using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    int a;
    REP(i, n) {
        cin >> a;
        v[i] = make_pair(a, i + 1);
    }
    sort(ALL(v));
    REP(i, n) {
        cout << v[i].second << " ";
    }
    cout << endl;
}


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

#define INF INT_MAX
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;

int main(){
    int n;
    cin >> n;
    vii score(n + 1, vi(3));
    for(int i=1; i<=n; i++){
        cin >> score[i][0] >> score[i][1] >> score[i][2];
    }
    vii dp(n + 1, vi(3, 0));
    for(int i=1; i<=n; i++){
        dp[i][0] = score[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = score[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = score[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include<iostream>

using namespace std;

int main(){

   int a,b,c;
   cin >> a >> b >> c;
   
   int s=0;
   for(int i = 0; i < 1000000;i++){
      s += a;
      if( s % b == c){
         cout << "YES" << endl;
         return 0;
      }
   }
   cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){
  int n;
  int cnt = 0;
  ll int ans = 0;
  ll int mind = 1e15;
  // cout << mind << endl;
  cin >> n;
  REP(i, n){
    ll int t;
    cin >> t;
    if(t<=0){
      cnt++;
    }
    ans += abs(t);
    mind = min(abs(t), mind);
  }
  if(cnt%2==1){
    cout << ans - 2 * mind << endl;
  }else{
    cout << ans << endl;
  }
}	
	

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

int main(){
    long long i=0,n,k;
    cin >> n >> k;
    vector<int> a(n);
    map<int,int>Map;
    Map[1]=1;
    for(i=0;i<n;i++){
        cin >> a.at(i);
    }
    int tmp=a.at(0),count=0;
    while(true){
        count++;
        Map[tmp]++;
        if(Map[tmp]==2)break;
        tmp=a.at(tmp-1);
    }
    //cout << tmp << endl;
    //cout << count << endl;
    if(tmp==1){
        k %= count;
        tmp=1;
        for(int i=0;i<k;i++){
            tmp=a.at(tmp-1);
        }
        cout << tmp << endl;
    }
    else{
        map<int,int>Mappp;
        long long countmade=0,tmppp=1;
        while(true){
            countmade++;
            tmppp=a.at(tmppp-1);
            if(tmppp==tmp)break;
        }
        //cout << countmade << endl;
        long long shuki = count - countmade;
        if(k<=countmade){
            tmp=1;
            for(int i=0;i<k;i++){
            tmp=a.at(tmp-1);
            }
            cout << tmp << endl;
        }
        else{
            k-=countmade;
            k%=shuki;
            //cout << k << " " << tmp << endl;
            for(int i=0;i<k;i++){
            tmp=a.at(tmp-1);
            }
            cout << tmp << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <int> A(N);
  for (int i=0;i<N;i++) {
    cin >> A.at(i);
  }
  int count=0;
  int finished=0;
  while(count >=0) {
    for(int j=0;j<N;j++) {
      if(A.at(j)%2 ==1) {
        finished =1;
        break;
      }
      else {
        A.at(j) = A.at(j) / 2;
      }
    }
    if(finished == 1) {
      break;
    }
    else {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector> 

using namespace std;

int main() {
	int n, d[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d, d + n);
	int m = 0;
	for (int i = 0; i < n - 1; i++) {
		if (d[i] < d[i + 1])m++;
	}
	cout << m + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
x=[0]+[-1]*110000

ma=0
for i in range(N):
    w,v=map(int,input().split())

    for j in range(len(x))[::-1]:# j: len(x)から1ずつ減る
        if x[j]>=0:
            if  x[j]+w<=W:
                if x[j+v]<0:
                    x[j+v]=x[j]+w
                    ma=max(ma,j+v)
                else:
                    x[j+v]=min(x[j+v],x[j]+w)

print(ma)

Measured memory_bytes: 42384
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            String s = sc.nextLine();
            int q = Integer.parseInt(sc.nextLine());
            if (s.length() > 1000 || s.length() < 1
                    || q > 100 || q < 1) {
                throw new IllegalTestCaseException();
            }
            while (sc.hasNext()) {
                String[] c_a_b_p = sc.nextLine().split(" ");
                String c = c_a_b_p[0];
                int a = Integer.parseInt(c_a_b_p[1]);
                int b = Integer.parseInt(c_a_b_p[2]);
                if (c.equals("replace")) {
                    s = replace(s, a, b, c_a_b_p[3]);
                } else if (c.equals("reverse")) {
                    s = reverse(s, a, b);
                } else if (c.equals("print")) {
                    System.out.println(s.substring(a, b + 1));
                } else {
                    throw new IllegalTestCaseException();
                }
            }
        } catch (IllegalTestCaseException
                | NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }

    private static String replace(String s, int a, int b, String ns) {
        String f = "", m = "", l = "";
        if (a != 0) {
            f = s.substring(0, a);
        }
        m = ns;
        if (b != s.length()) {
            l = s.substring(b + 1);
        }
        return f.concat(m).concat(l);
    }

    private static String reverse(String s, int a, int b) {
        char[] cs = s.toCharArray();
        char[] ncs = cs.clone();
        for (int i = 0; i <= b - a; i++) {
            ncs[a + i] = cs[b - i];
        }
        return String.valueOf(ncs);
    }

    private static class IllegalTestCaseException extends RuntimeException {
        IllegalTestCaseException() {
            super("Illegal condition.");
        }
    }
}



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

int main() {
 
  int a, b;
  	1 <= a;
    b <= 100;
  cin >> a >> b;
  
  int c;
  c = a + b;
  
if(c % 2 == 0){
   cout << c / 2 << endl;
}else{
  cout << c / 2 + 1 << endl;
  }
  
}


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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

void solve(string s){
	int ans = INF;
	for(char c = 'a';c <= 'z';c++){
		vector<int> pos;
		REP(i,s.size()){
			if(s[i]==c){
				pos.push_back(i);
			}
		}
		if(pos.size()==0)continue;
		int ans0;
		ans0 = max((int)pos.front(),(int)s.size()-1-pos.back());
		REP(i,pos.size()-1){
			int len = pos[i+1]-pos[i]-1;
			ans0 = max(ans0,len);
		}
		ans = min(ans,ans0);
	}
	cout<<ans<<endl;
}

int main(){	
	string s;
	cin >> s;
	solve(s);
	return 0;
}



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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    cout << (s[s.size() - 1] == 's' ? s + "es" : s + "s") << '\n';

    return 0;
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); 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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  char c;
  set<string> st;
  rep(i, n) {
    string s; cin >> s;
    if (st.find(s) != st.end()) {
      cout << "No" << endl;
      return 0;
    }
    if (i!=0) {
      if (c != s.front()) {
        cout << "No" << endl;
        return 0;
      }
    }
    c = s.back();
    st.insert(s);
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
using Tree = vector<pair<int, int>>;
int main()
{
    int n, m;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    cin >> m;
    vector<int> t(m);
    for (int i = 0; i < m; i++)
    {
        cin >> t[i];
    }
    sort(d.begin(), d.end());
    sort(t.begin(), t.end());
    int j = 0;
    bool ans = true;
    for (int i = 0; i < m; i++)
    {
        while (t[i] > d[j])
            j++;
        if (t[i] != d[j])
        {
            ans = false;
            break;
        }
        else
            j++;
    }
    cout << (ans ? "YES" : "NO") << endl;
}

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

using namespace std;

int main()
{
  int N;
  //int A[100100];
  cin >> N;
  
  int oddCount=0;
  int everCount = 0;
  for(int i=0; i<N;++i) {
    //cin >> A[i];
    int a;
    cin >> a;
    if(a % 2 == 0) {
      everCount++;
    } else {
      oddCount++;
    }
    //A[i] = a;
  }
  
  bool isOK = oddCount % 2 == 0;
  
  if(isOK) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n,k;
    cin>>n>>k;
    vector<int>a(n+1);
    rrep(i,n) cin>>a[i];
    vector<bool>isHigher(n+1,false);
    for(int i = k+1; i <= n; i++){
        if(a[i]>a[i-k]) isHigher[i] = true;
    }
    for(int i = k+1; i <= n; i++){
        if(isHigher[i])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3972
N, K = map(int, input().split())
S = list(input())

# 同じ方向を向いている人の圧縮処理                                                       
S_pack = [S[0]]
for direction in S:
    if S_pack[-1] != direction:
        S_pack.append(direction)
n_unhappy = len(S_pack)
n_unhappy = max(n_unhappy - K*2, 1)

print(N - n_unhappy)

Measured memory_bytes: 4648
# reference

n, m = map(int, input().split())

adj = [list() for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)

#print(adj)
#print(list(enumerate(adj)))

loop = True
bridge = 0
while loop:
    loop = False
    for i, ai in enumerate(adj):
        if len(ai) == 1:
            adj[i] = []
            adj[ai[0]].remove(i)
            bridge += 1
            loop = True

#print(adj)
print(bridge)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vi A(M),P={2,5,5,4,5,6,3,7,6};
  rep(i,0,M) cin>>A[i];
  vector<string> dp(N+1,"-1");
  dp[0]="";
  REP(i,1,N){
    rep(j,0,M){
      int X=P[A[j]-1];
      if(i-X>=0&&dp[i-X]!="-1"){
        string S=dp[i-X];
        S+='0'+A[j];
        sort(ALL(S),greater<char>());
        if(dp[i]=="-1") dp[i]=S;
        else if(S.size()>dp[i].size()) dp[i]=S;
        else if(S.size()==dp[i].size()&&S>dp[i]) dp[i]=S;
      }
    }
  }
  cout<<dp[N]<<endl;
  }


Measured memory_bytes: 25344
/******
author :- Mahmoud Tarek.
*******/

#include<bits/stdc++.h>

using namespace std ;

#define rg register
#define dbg(v) cerr << #v << " " << v ;
typedef long long ll ;

int n, w ;
vector<pair<int, int>> a ;
const int N = 1e5 + 5 ;
ll dp[101][N] ;

int main() {
//  freopen("in.txt", "r", stdin) ;

    cin >> n >> w ;
    a.resize(n) ;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i].first >> a[i].second ;
    }

    for(int i = 1 ; i <= n ; i++){
        for(int j = 0 ; j <= w ; j++){
            if(j >= a[i - 1].first){
              dp[i][j] = max(dp[i - 1][j], a[i - 1].second + dp[i - 1][j - a[i - 1].first]) ;
            } else {
              dp[i][j] = dp[i - 1][j] ;
            }
        }
    }

    cout << dp[n][w] << "\n" ;





}


/*
  Empty set of troubles.
*/



Measured memory_bytes: 78336
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws java.io.IOException {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            double xa1 = sc.nextDouble();
            double ya1 = sc.nextDouble();
            double xa2 = sc.nextDouble();
            double ya2 = sc.nextDouble();
            double xb1 = sc.nextDouble();
            double yb1 = sc.nextDouble();
            double xb2 = sc.nextDouble();
            double yb2 = sc.nextDouble();
            System.out .println(xb1 > xa2 ||
                                yb1 > ya2 ||
                                xb2 < xa1 || yb2 < ya1 ? "NO"
                                                       : "YES");
        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define fix cout<<fixed<<setprecision(20);
const int maxn=(int)1e6+5;
char mp[11][maxn];
int c[11],re,cnt;
int h,w,k;
bool f(int j,int z){
    int id=0;
    rep(i,0,h-1){
        c[id]+=mp[i][j]=='1';
        if(c[id]>k)return 0;
        if((z>>i)&1)id++;
    }
    return 1;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>h>>w>>k;
    rep(i,0,h-1)cin>>mp[i];
    int ans=10000;
    for(int i=0;i<(1<<h)-1;i++){
        fill(c,c+h,0);re=1;
        cnt=__builtin_popcount(i);
        rep(j,0,w-1){
            if(!f(j,i)){
                fill(c,c+h,0);
                re=f(j,i);
                cnt++;
            }
            
        }
        if(re)ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}
/* 
3 5 4
11100
10001
00111

 */

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

using namespace std;

int N, Q;
vector<int> vec;

int main(void)
{
	cin >> N >> Q;
	
	int v, w;
	for(int i = 0; i < Q; i++){
		cin >> v >> w;
		
		if(N == 1){
			cout << min(v, w) << endl;
			continue;
		}
		
		vec.clear();
		while(v > 0){
			vec.push_back(v);
			v = (v + (N-2)) / N;
		}
		reverse(vec.begin(), vec.end());
		int ans;
		while(w > 0){
			if(w == *lower_bound(vec.begin(), vec.end(), w)) {
				ans = w;
				break;
			}
			w = (w + (N-2)) / N;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
    long long n, l, t;
    cin >> n >> l >> t;
    vector<long long> x(n), w(n), last(n), ans(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> w[i];
    for(int i = 0; i < n; i++) {
        if(w[i] == 1) last[i] = (x[i] + t) % l;
        else last[i] = ((x[i] - t) % l + l) % l;
    }
    sort(last.begin(), last.end());
    long long cnt = 0;
    for(int i = 0; i < n; i++) {
        if(w[i] == 1) cnt -= (t - (l - x[i]) + l) / l;
        else cnt += (t - (x[i] + 1) + l) / l;
    }
    cnt = (cnt % n + n) % n;
    for(int i = 0; i < n; i++) ans[(i + cnt) % n] = last[i];
    for(int i = 0; i < n; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 6252
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    if(s=="SSS"){
        cout<<0<<endl;
        return 0;
    }
    int cnt=0;
    for (int i = 0; i < s.size()-1; i++)
    {
        if(s[i]=='R' && s[i+1]=='R') cnt++;
    }
    cout<<cnt+1<<endl;
    return 0;
}

Measured memory_bytes: 3640
#import time
#start = time.time()

def isPrimeNumber(a):
    for i in range(2, int(a**0.5)+1):
        if a % i == 0:
            return False
    return True


n = int(input())
data = [int(input()) for i in range(n)]

count = 0
for a in data:
    if isPrimeNumber(a):
        count += 1
print(count)
#end = time.time()
#print(end - start)

Measured memory_bytes: 8116
#include "bits/stdc++.h"
#define rep(i,N) for(int (i) = 0;(i) < (N); (i)++)
int main(){
    std::cin.tie(nullptr);std::ios::sync_with_stdio(false);

    int ans = 0;
    int n;std::cin>>n;
    std::vector<int> p(n);
    rep(i,n)std::cin>>p[i];
    rep(i,n-2){
        std::array<int,3> arr;
        arr[0] = p[i];
        arr[1] = p[i+1];
        arr[2] = p[i+2];
        int tmp = arr[1];
        std::sort(arr.begin(),arr.end());
        if(tmp == arr[1])ans++;
    }
    std::cout<<ans;

    return 0;
}


Measured memory_bytes: 384
# coding: utf-8


def main():

    str_count, _ = map(int, input().split(' '))
    str_join = []

    for _ in range(str_count):
        str_join.append(input())
        
    str_join = sorted(str_join)    

    print(''.join(str_join))

    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import math
a, b, h, m = map(int, input().split())

time = h * 60 + m  #経過時間(m)
h_theta = (0.50 * time) % 360
m_theta = (6.0 * time) % 360

h_pos = [a * math.cos(math.radians(h_theta)), a * math.sin(math.radians(h_theta))]
m_pos = [b * math.cos(math.radians(m_theta)), b * math.sin(math.radians(m_theta))]

x = abs(h_pos[0] - m_pos[0])
y = abs(h_pos[1] - m_pos[1])

dist = math.sqrt(x ** 2 + y ** 2)

print(dist)

Measured memory_bytes: 9600
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	boolean [] used;
	boolean [][] pass;
	int len = 26;

	private void doit() {
		while (sc.hasNext()) {
			int n = sc.nextInt();
			if(n == 0) break;
			pass = new boolean[len][len];
			int [][] count = new int[len][2];
			for(int i = 0; i < n; i++){
				String s = sc.next();
				int first =  s.charAt(0) - 'a';
				int end = s.charAt(s.length()-1) - 'a';
				count[first][0]++;
				count[end][1]++;
				pass[first][end] = true;
			}
			
			boolean flg = true;
			for(int i = 0; i < len; i++){
				if(count[i][0] != count[i][1]){
					flg = false;
					break;
				}
			}
			if(! flg){
				System.out.println("NG");
				continue;
			}
			used = new boolean[len];
			int ind = -1;
			for(int i = 0; i < len; i++){
				if(count[i][0] > 0){
					ind = i;
					break;
				}
			}
			dfs(ind);
			boolean flg2 = true;
			for(int i = 0; i < len; i++){
				if(! used[i] && count[i][0] > 0){
					flg2 = false;
					break;
				}
			}
			System.out.println(flg2 ? "OK" : "NG");
		}
	}

	private void dfs(int ind) {
		used[ind] = true;
		for(int i = 0; i < len; i++){
			if(used[i]) continue;
			if(pass[ind][i]){
				dfs(i);
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl

int main() {
  ll n,m;
  cin >> n >> m;
  vector<vl> pp(n,vl(2));
  REP(i,n){
    cin >> pp[i][0];
    cin >> pp[i][1];
  }
  sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});
  ll ans = 0;
  REP(i,n){
    ll tm = min(m,pp[i][1]);
    ans += tm * pp[i][0];
    m -= tm;
  }
  cout << ans << endl;
  return 0;
}


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

using Elem = std::pair<int, int>;

int main()
{
	int N;
	static Elem ab[200000], ba[200000];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d%d", &ab[i].first, &ab[i].second);
		ba[i].first = ab[i].second;
		ba[i].second = ab[i].first;
	}

	std::sort(ab, ab + N);
	std::sort(ba, ba + N);
	std::reverse(ba, ba + N);

	if (N % 2 == 0) {
		int mid1 = N / 2 - 1;
		int mid2 = N / 2;
		int a = ab[mid1].first + ab[mid2].first;
		int b = ba[mid1].first + ba[mid2].first;
		printf("%d\n", b - a + 1);
	}
	else {
		int mid = N / 2;
		printf("%d\n", ba[mid].first - ab[mid].first + 1);
	}

	return 0;
}


Measured memory_bytes: 4836
//見　た　な
//見たな
//見　た　な

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

int memo[101]; //N!の素因数分解した時のiの指数
//各素因数の数が基準以上であればよい

//memoの内、引数xに対しx以上のものの個数
int num(int x){
    int cnt = 0;
    for(int i = 1; i < 101; i++){
        if(memo[i] >= x) cnt++;
    }
    return cnt;
}

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

    //N！の素因数分解をmemoに保存
    int cur;
    for(int i = 2; i < n+1; i++){
        cur = i;
        for(int j = 2; j < i + 1; j++){
            while(cur % j == 0){
                memo[j]++;
                cur /= j;    
            }
        }
    }
    //要素数を見ていく
    //2つ選ぶ時は要素数の大きいものから選んで、次は同じのを選ばないようにすればいいので1引いたものをかける
    //3つの場合重複を避けるために2で割れば十分
    cout << num(74) + num(24)*(num(2)-1) + num(14)*(num(4)-1) + num(4)*(num(4)-1)*(num(2)-2)/2 << endl;
}

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

void gcm(int a, int b) {
    if (a < b) swap(a, b);
    int c;
    while (true) {
        c = a % b;
        if (c == 0) break;
        a = b;
        b = c;
    }
    
    cout << b << endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    gcm(a, b);
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int leftcnt[2005][2005];
int rightcnt[2005][2005];
int upcnt[2005][2005];
int downcnt[2005][2005];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int h,w; cin >> h >> w;
    char field[2005][2005];
    rep(i,0,h){
        rep(j,0,w) cin >> field[i][j];
    }

    rep(i,0,h){
        int cnt = 0;
        rep(j,0,w){
            if(field[i][j] == '.'){
                cnt++;
            }else{
                cnt = 0;
            }
            leftcnt[i][j] = cnt;
        }
    }

    rep(i,0,h){
        int cnt = 0;
        for(int j=w-1;j>=0;j--){
            if(field[i][j] == '.'){
                cnt++;
            }else{
                cnt = 0;
            }
            rightcnt[i][j] = cnt;
        }
    }

    rep(j,0,w){
        int cnt = 0;
        rep(i,0,h){
            if(field[i][j] == '.'){
                cnt++;
            }else{
                cnt = 0;
            }
            upcnt[i][j] = cnt;
        }
    }

    rep(j,0,w){
        int cnt = 0;
        for(int i=h-1;i>=0;i--){
            if(field[i][j] == '.'){
                cnt++;
            }else{
                cnt = 0;
            }
            downcnt[i][j] = cnt;
        }
    }

    int ans = 0;
    rep(i,0,h){
        rep(j,0,w){
            int tmp = leftcnt[i][j] + rightcnt[i][j] + upcnt[i][j] + downcnt[i][j] - 3;
            chmax(ans, tmp);
        }
    }

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


Measured memory_bytes: 70244
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

b_sum = sum(B)
for i in range(M - 1, -1, -1):
    if b_sum <= K:
        j = i
        break
    b_sum -= B[i]
else:
    j = -1
result = j + 1

a_sum = 0
for i in range(N):
    a_sum += A[i]
    if a_sum > K:
        break
    while a_sum + b_sum > K:
        b_sum -= B[j]
        j -= 1
    result = max(result, (i + 1) + (j + 1))
print(result)


Measured memory_bytes: 40624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;


int main(){
    ll N,M;
    cin>>N>>M;
    if(N==1&&M==1)cout<<1<<endl;
    else if(N==1){
        cout<<M-2<<endl;
    }
    else if(M==1)cout<<N-2<<endl;
    else cout<<N*M-2*(N-2+M-2)-4<<endl;
}






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

  bool flag = false;//水やり済みならtrue, ansが更新されたタイミングでfalseへ戻す
  int ans = 0;
  for(;;){
    for(int i=0;i<N;i++){
      if(h[i]>0){
        h[i]-=1;
        flag = true;
      }else if(flag){
        break;
      }
    }
    if(flag){
      ans+=1;
    }else{
      break;
    }
    flag = false;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
using namespace std;
int cnt=1;
vector<long long> v(0);
int Sub(string s,int size){
  if(cnt==size+1) return 0;
  long long sum = stoll(s.substr(0,cnt));
  for(int i=1;i<cnt;i++){
    sum+=stoll(s.substr(i,cnt-i))*pow(2,i-1); 
  }
  for(int i=0;i<v.size();i++){
    sum+=v[i];
  }
  v.push_back(sum);
  cnt++;
  Sub(s,size);
  return 1;
}
int main(){
  string s;
  cin >> s;
  int b=Sub(s,s.size());
  cout << v[v.size()-1] << "\n";
    
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> >vvi;
const ll MOD=1000000007LL;
//素数判定O(√n)
bool is_prime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0)return false;
  }
  return n!=1;
}
int main(){
  int n;
  cin>>n;
  vector<int>l(n),r(n);
  rep(i,n)cin>>l[i]>>r[i];
  int table[100010];
  int count=0;
  table[0]=0;
  for(int i=1;i<=100010;i++){
    if(i%2==1){
      if(is_prime(i) && is_prime((i+1)/2)){
        count++;
      }
    }
    table[i]=count;
  }
  rep(i,n){
    cout<<table[r[i]]-table[l[i]-1]<<endl;
  }
}
  
    
    
  

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, sum = 1; cin >> n;
	for (int h = 0; h < 30; h++) {
		sum *= 2;
		if (sum > n) {
			cout << sum / 2 << endl;
			cin >> n; return 0;
		}
	}
	cin >> n;
}


Measured memory_bytes: 3120
s = input()
K = int(input())
l = len(s)
dic = {}
for i in range(l):
	if not s[i] in dic:
		dic[s[i]] = []
	for j in range(1,6):
		if i + j > (l):
			break
		else:
			dic[s[i]].append(s[i:i+j])

lst = list(dic.keys())
lst.sort()
for c in lst:
	dic[c] = sorted(set(dic[c]))
	l = len(dic[c])
	if K > l:
		K -= l
	else:
		print(dic[c][K-1])
		exit(0)

Measured memory_bytes: 4468
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops"
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 998244353
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double

void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
// char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=3e5+5;
ll n , m , a[maxN];

ll _rank(ll x ){
    if(a[x]==x)return x ;
    return a[x] = _rank(a[x]);
}

void _union(ll x , ll y){
    ll ps = _rank(x);
    ll ss = _rank(y);
    if(ps!=ss){
        a[ps]= ss ;
    }
}
void solve(){
   cin>> n >> m ;
   
   for(ll i=0 ; i<=n ;i++)a[i]=i;
   for(ll i=0 , x , y;i<m ; i++){
       cin>>x >> y ;
       _union(x , y);
   }
   
   for(ll i=1;i<=n ;i++)_rank(i);
   ll ans = 0 ;
   set<ll> st ;
   for(ll i=1;i<=n ;i++){
    //   cerr<<a[i]<<" ";
       st.insert(a[i]);
   }
   ans=(ll)st.size()-1;
   cout<<ans<<endl;
    
}

int main(){
// 	mahakal();
	fast;
	ll t =1 ;
// 	cin>> t ; 
	while(t--)solve();
// 	cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}


Measured memory_bytes: 8328
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();

	System.out.println((H-h)*(W-w));
      }
      }

Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
constexpr auto INF = 2147483647;
typedef long long ll;

int tri(int a){
  return a*(a+1)/2*(a+2)/3;
};

static const int MAX = 1000005;

int main(){
  int x, max_n;
  int DP[MAX], DP_ODD[MAX], tri_list[200];
  vector<int> tri_list_odd;
  fill(DP, DP+MAX,INF);
  fill(DP_ODD,DP_ODD+MAX,INF);
  rep(i,200){
    tri_list[i] = tri(i+1);
    if(tri_list[i]%2 != 0) tri_list_odd.emplace_back(tri_list[i]);
  } 
  DP[0] = 0;
  DP_ODD[0] = 0;
  rep(i,200){
    for(int j = tri_list[i];j<MAX;j++){
      DP[j] = min(DP[j], DP[j-tri_list[i]]+1);
    }
  }
  rep(i,tri_list_odd.size()){
    for(int j = tri_list_odd[i];j<MAX;j++){
      DP_ODD[j] = min(DP_ODD[j],DP_ODD[j-tri_list_odd[i]]+1);
    }
  }

  while(true){
    cin >> x;
    if(x == 0)break;
    cout << DP[x] << " " << DP_ODD[x] << endl;
  }

  return 0;
}


Measured memory_bytes: 10964
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	int N = 0;
	int count[100] = {0};
	int maxCount = 0;
	int ans = 1;
	cin >> N;
	for (int i = 1;i<=N;i++) {
		int num = i;
		while (num%2!=1) {
			num = num / 2;
			count[i]+=1;
		}

	}
	for (int i = 1; i <= N; i++) {
		if (maxCount<count[i]) {
			maxCount = count[i];
			ans = i;
		}

	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n;
  cin >> n;
  ll dp[200000][3]={},a[n],b[n],c[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  for(int i=0;i<n;i++){
    dp[i+1][0] = max(dp[i][1],dp[i][2])+a[i];
    dp[i+1][1] = max(dp[i][0],dp[i][2])+b[i];
    dp[i+1][2] = max(dp[i][0],dp[i][1])+c[i];
  }
  cout << max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}


Measured memory_bytes: 7296
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long x = long.Parse(Console.ReadLine());
		long answer = 0;
    long memo = 0;
    for(int i = 1; i > 0; i++)
    {
      memo += i;
      answer++;
      if(x <= memo) break;
    }
		
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 13140