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

char c[55][55];
int h,w,cnt;

int main()
{
	cin >> h >> w;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			cin >> c[i][j];
		}
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(c[i][j]=='#'&&c[i][j-1]!='#'&&c[i-1][j]!='#'&&c[i][j+1]!='#'&&c[i+1][j]!='#') cnt++;
	if(!cnt) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

namespace ProjectContest
{
    class Test
    {
        static void Main()
        {
            var nx = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            int n = nx[0], x = nx[1];
            var L = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32).ToList() ;
            int kq = 1;
            L.Insert(0, 0);
            for(int i = 1; i < n+1; i++)
            {
                L[i] = L[i] + L[i - 1];
                if (L[i] <= x)
                    kq++;
                else break;
            }
            Console.WriteLine(kq);
        }
    }
}

Measured memory_bytes: 13268
r, g, b = [int(i) for i in input().split()]
K = int(input())

# g 
cnt = 0
while g <= r:
  g *= 2
  cnt += 1
  
# b
while b <= g:
  b *= 2
  cnt += 1

  
if K < cnt:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h,w,k;
    cin >> h >> w >> k;
    char maze[h][w];
    rep(i,h) rep(j,w) cin >> maze[i][j];
    int allblack =0;
    rep(i,h) rep(j,w) if (maze[i][j] == '#') allblack++;
    int ans = 0;

    rep(i,(1<<h)) rep(j, (1<<w))
    {
        int tmpn =0;
        rep(k, h) rep(m, w)
        {
            if (maze[k][m]=='#' && !((i >> k) & 1) && !((j >> m) & 1))
            {
                tmpn++;
            }
        }
        if (tmpn == k) ans++;
    }
    cout << ans << endl;

}


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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s; std::cin >> s;
    while (s.size() > 2) {
        s.pop_back();
        if (s.size() % 2) continue;
        int len = s.size()/2;
        bool ok = true;
        rep(i, len) {
            if (s[i] != s[len+i]) ok = false;
        }
        if (ok) {
            std::cout << len*2 << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> ans(n + 1, 0);
  for (int x = 1; x * x < n; ++x) for (int y = 1; y * y < n; ++y) for (int z = 1; z * z < n; ++z) {
    if (x * x + y * y + z * z + x * y + y * z + z * x <= n) {
      ++ans[x * x + y * y + z * z + x * y + y * z + z * x];
    }
  }
  FOR(i, 1, n + 1) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 3648
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	chunks := strings.Split(sc.Text(), " ")
	n, _ := strconv.Atoi(chunks[0])
	a, _ := strconv.Atoi(chunks[1])
	b, _ := strconv.Atoi(chunks[2])

	fmt.Println(int(math.Min(float64(n*a), float64(b))))
}


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

using namespace std;

const int N = 1000;

int h, w, n, dp[N][N], data[N][N];

main(){
  while(cin >> h >> w >> n && (h|w|n)){
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> data[i][j];
    dp[0][0] = n-1;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(i == 0 && j == 0) continue;
        int s = 0, e = 0;
        if(i){
          if(dp[i-1][j] % 2){
            if(!data[i-1][j]) s = (dp[i-1][j] + 1) / 2;
            else s = (dp[i-1][j] - 1) / 2;
          }else s = dp[i-1][j] / 2;
        }
        if(j){
          if(dp[i][j-1] % 2){
            if(data[i][j-1]) e = (dp[i][j-1] + 1) / 2;
            else e = (dp[i][j-1] - 1) / 2;
          }else e = dp[i][j-1] / 2;
        }
        dp[i][j] = s + e;
      }
    }
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(dp[i][j] % 2) data[i][j] = 1 - data[i][j];
    int y = 0, x = 0;
    while(1){
      if(y >= h || x >= w) break;
      if(data[y][x]) x++;
      else y++;
    }
    cout << y + 1 << ' ' << x + 1 << endl;
  }
}

Measured memory_bytes: 5556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define loop(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
   string s;
   cin >> s;
   reverse(s.begin(), s.end());
   vector<string> c{"dream", "dreamer", "erase", "eraser"};
   loop(x, 4) {
      reverse(c[x].begin(), c[x].end());
   }
   int i = 0;
   while (i < s.length()) {
      if (s.substr(i, 5) == c[0] || s.substr(i, 5) == c[2]) {
         i += 5;
      }
      else if (s.substr(i, 6) == c[3]) {
         i += 6;
      }
      else if (s.substr(i, 7) == c[1]) {
         i += 7;
      }
      else
      {
         cout << "NO" << endl;
         return 0;
      }
   }
   cout << "YES" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,nx,ny;
  int a[]={1,3,5,7,8,10,12};
  int b[]={4,6,9,11};
  cin>>x>>y;
  for(int i=0;i<7;i++){
    if(x==a[i])nx=1;
    if(y==a[i])ny=1;
  }
  for(int i=0;i<4;i++){
    if(x==b[i])nx=2;
    if(y==b[i])ny=2;
  }
  if(x==2)nx=3;
  if(y==2)ny=3;
  if(nx==ny)cout<<"Yes";
  else cout<<"No";
  cout<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
 
#define MAX 101
 
void MatrixChain();
 
int n,p[MAX],M[MAX][MAX];
 
int main(){
 
  int i;
 
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
 
  MatrixChain();
   
  printf("%d\n",M[1][n]);
 
  return 0;
}
 
void MatrixChain(){
  int i,j,k,l,q;
 
  for(i=1;i<n;i++) M[i][i]=0;
 
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      M[i][j] = INT_MAX;
      for(k=i;k<j;k++){
    q=M[i][k]+M[k+1][j]+p[i-1]*p[k]*p[j];
    if(q<M[i][j]) M[i][j]=q;
      }
    }
  }
}

Measured memory_bytes: 636
n = gets.chomp.to_i
a = gets.chomp.split("\s").map(&:to_i)

for i in 0...a.length do
    a[i] = a[i] - i
end

a.sort!
b = a[a.length / 2]

result = 0
a.each do |item|
  result += (item - b).abs
end

puts result

Measured memory_bytes: 19456
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        sum += w[i];
    }
    int ans = 1000000;
    int last = 0;
    for(int i = 0; i < n; i++){
        last += w[i];
        ans = min(ans, abs(sum - 2 * last));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lson (k<<1)
#define rson (k<<1|1)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl
#define rep(i,s,t) for(int i=(s),_t=(t);i<_t;++i)
#define per(i,s,t) for(int i=(t)-1,_s=(s);i>=_s;--i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=(int)1e9+7;
template<class T>void rd(T &x)
{
	x=0;
	static char c;
	while(c=getchar(),c<48);
	do x=x*10+(c^48);
		while(c=getchar(),c>47);
}
void ptn(ll x)
{
	static char stk[65];
	int tp=0;
	for(;x;x/=10)stk[tp++]=x%10^48;
	per(i,0,tp)putchar(stk[i]);
	putchar('\n');
}
template<class T>inline void Max(T &a,T b)
{
	if(b>a)a=b;
}
template<class T>inline void Min(T &a,T b)
{
	if(b<a)a=b;
}
// EOT


const int N=(int)1e5+5;

int fact[N];

int main()
{
	int n,m;
	cin>>n>>m;
	if(abs(n-m)>1)return puts("0"),0;
	fact[0]=1;
	rep(i,1,N)fact[i]=(ll)fact[i-1]*i%mod;
	int ans;
	if(n==m)ans=2ll*fact[n]*fact[m]%mod;
	else ans=(ll)fact[n]*fact[m]%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF (1e9)
#define TOP 0
#define FRONT 1 
#define LEFT 2
#define RIGHT 3
#define BACK 4
#define BOTTOM 5
#define N 30
using namespace std;

//TOP,FRONT,LEFT,RIGHT,BACK,BOTTOM
char dice[6];
char clist[6]={'r','m','y','b','g','c'};

void init(){
  for(int i=0;i<6;i++)
    dice[i]=clist[i];
}

//?\\?????¢??????
void rotN(){
  swap(dice[TOP],dice[FRONT]);
  swap(dice[FRONT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[BACK]);
}

//???????????¢??????
void rotS(){
  //rotN(),rotN(),rotN();
  swap(dice[TOP],dice[BACK]);
  swap(dice[BACK],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[FRONT]);
}

//????????¢??????
void rotE(){
  swap(dice[TOP],dice[LEFT]);
  swap(dice[LEFT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[RIGHT]);
}

//????????¢??????
void rotW(){
  //rotE(),rotE(),rotE();
  swap(dice[TOP],dice[RIGHT]);
  swap(dice[RIGHT],dice[BOTTOM]);
  swap(dice[BOTTOM],dice[LEFT]);
}


string s[N],t;
int h,w;
int ctoi[300];

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

int check(int ny,int nx,int p){
  if(ny<0||nx<0||h<=ny||w<=nx)return 2;
    
  char c=s[ny][nx];
  
  if(c=='k')return 2;
  
  if(c=='w')return 0;
  
  if(c==t[p]&&c==dice[TOP])return 1;
  
  return 2;
}

void Rot(int dir){
  if(dir==0)rotN();
  if(dir==1)rotE();
  if(dir==2)rotS();
  if(dir==3)rotW();
}

struct dat{
  int cost,y,x,p;
  char dice[6];
  dat(){};
  dat(int a,int b,int c,int d){cost=a,y=b,x=c,p=d;};
};

int d[N][N][7][6][6];

int bfs(int sy,int sx){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      for(int k=0;k<7;k++)
	for(int l=0;l<6;l++)
	  for(int m=0;m<6;m++)
	    d[i][j][k][l][m]=INF;
  
  d[sy][sx][0][ctoi[dice[TOP]]][ctoi[dice[FRONT]]]=0;
  
  queue<dat> q;
  
  dat A=dat(0,sy,sx,0);
  for(int i=0;i<6;i++)A.dice[i]=dice[i];
  
  q.push(A);
  
  while(!q.empty()){
    dat u=q.front(); q.pop();
    
    if(u.p==6)return u.cost;
    
    for(int i=0;i<4;i++){
      int ny=u.y+dy[i],nx=u.x+dx[i],ncost=u.cost+1;
      
      for(int j=0;j<6;j++)dice[j]=u.dice[j];
      
      Rot(i);
      
      int r=check(ny,nx,u.p);
      
      if(r==2)continue;
      
      if(d[ny][nx][u.p+r][ctoi[dice[TOP]]][ctoi[dice[FRONT]]]>ncost){
	d[ny][nx][u.p+r][ctoi[dice[TOP]]][ctoi[dice[FRONT]]]=ncost;
	dat A=dat(ncost,ny,nx,u.p+r);
	for(int j=0;j<6;j++)A.dice[j]=dice[j];
	q.push(A);
      }
      
    }

  }
  
  return INF;
}

int main(){
  ctoi['r']=0;  ctoi['m']=1;
  ctoi['y']=2;  ctoi['b']=3;
  ctoi['g']=4;  ctoi['c']=5;
  
  while(1){
    
    cin>>w>>h;
    if(!h&&!w)break;
    
    int sy,sx;
    for(int i=0;i<h;i++){
      cin>>s[i];
      
      for(int j=0;j<w;j++)
	if(s[i][j]=='#'){
	  sy=i,sx=j;
	  s[i][j]='w';
	}
      
    }
    cin>>t;
    
    init();
    int ans=bfs(sy,sx);
    
    if(ans==INF) cout<<"unreachable"<<endl;
    else cout<<ans<<endl;
    
  }
  return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define LL int
using namespace std;
const int mod = 998244353;
const int maxn = 3010;
int dp[maxn];
void add(int &x ,int y){
  x+=y;
  if(x>=mod) x-=mod;
}
int main(){
  	int n,s,x;
  	cin>>n>>s;
  
  	dp[0] = 1;
  	for (int i=1;i<=n;i++){
      cin>>x;
      for (int j=s;j>=x;j--){
      	add(dp[j],dp[j]);
        add(dp[j],dp[j-x]);
      }
      for (int j=x-1;j>=0;j--) add(dp[j],dp[j]);
    }
  	cout<<dp[s]<<endl;
	return 0;
}

Measured memory_bytes: 3604
s = gets.chomp
s1 = s[0..1].to_i
s2 = s[2..3].to_i
if s1 >= 1 && s1 <= 12 && s2 >= 1 && s2 <= 12
  puts 'AMBIGUOUS'
elsif s1 >= 1 && s1 <= 12
  puts 'MMYY'
elsif s2 >= 1 && s2 <= 12
  puts 'YYMM'
else
  puts 'NA'
end


Measured memory_bytes: 1788
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

a = list(map(int,input().split()))
y(len(set(a)) == 2)

Measured memory_bytes: 5964
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int mod=1000000007;
int C[1100][1100];
vector<int>g[1100];
int sz[1100];
int in[1100];
long long dp[1100][1100];
long long dp2[210][210];
void solve(int a){
	sz[a]++;
	for(int i=0;i<g[a].size();i++){
		solve(g[a][i]);
		sz[a]+=sz[g[a][i]];
	}
	for(int i=0;i<210;i++)for(int j=0;j<210;j++)dp2[i][j]=0;
	dp2[0][0]=1;
	int now=0;
	for(int i=0;i<g[a].size();i++){
		for(int j=0;j<=now;j++){
			for(int k=1;k<=sz[g[a][i]];k++){
				for(int l=max(j,k);l<=j+k;l++){
					dp2[i+1][l]=(dp2[i+1][l]+dp2[i][j]*dp[g[a][i]][k]%mod*C[j][k-(l-j)]%mod*C[l][l-j])%mod;
				}
			}
		}
		now+=sz[g[a][i]];
	}
	for(int i=0;i<=now;i++)dp[a][i+1]=dp2[g[a].size()][i];
	//printf("%d: ",a);
	//for(int i=0;i<=now;i++)printf("%lld ",dp[a][i+1]);
	//printf("\n");
}
int main(){
	C[0][0]=1;
	for(int i=0;i<1050;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j+1]=(C[i+1][j+1]+C[i][j])%mod;
			C[i+1][j]=(C[i+1][j]+C[i][j])%mod;
		}
	}
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);
		g[p].push_back(q);
		in[q]++;
	}
	for(int i=0;i<a;i++){
		if(!in[i]){
			solve(i);
			long long ret=0;
			for(int j=0;j<210;j++)ret=(ret+dp[i][j])%mod;
			printf("%lld\n",ret);
		}
	}
}

Measured memory_bytes: 10416
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using p = pair<int, int>;
map<int, int> primes;
int getDigit(ll num) {
	int digit = 0;
	while (num != 0) {
		num /= ll(10);
		digit++;
	}
	return digit;
}
void decompositPrime(ll n)
{
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			primes[a]++;
			n /= a;
		}
		else {
			a++;
		}
	}
	if (n != 0 && n != 1) {
		primes[n]++;
	}
}
int main()
{
	ll n;
	cin >> n;
	decompositPrime(n);
	int ans = 0;
	int tmp = 0;
	for(auto m : primes) {
		tmp = 0;
		int i = 1;
		while (i*(i + 1) / 2 <= m.second) {
			i++;
			tmp++;
		}
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 3000;

LL a, b, c, d;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int main()
{
    cin >> a >> b >> c >> d;

    LL sum1 = b / c - (a - 1) / c;
    LL sum2 = b / d - (a - 1) / d;
    LL lcm = c * d / gcd(c, d);
    LL sum3 = b / lcm - (a - 1) / lcm;

    cout << (b - a + 1) - sum1 - sum2 + sum3 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

//約数列挙
ll div(long long a, vector<long long> &n) {
  n.push_back(1);
  for (long long i = 2; i <= sqrt(a); i++)
    if (a % i == 0) n.push_back(i);
  if (n.at(n.size() - 1) == sqrt(a)) return 0;
  else {
    if (n.size() == 4) return 1;
    else return 0;
  }
}

int main() {
  ll n;
  cin >> n;
  ll cnt = 0;
  for (ll i = 1; i <= n; i += 2) {
    vector<ll> m(0);
    cnt += div(i, m);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int length(int i,vector < int > &D,vector < vector < pair<int ,int > > > &E ){

if(D[i]!=-1)return D[i];

for(int j=0;j<E[i].size();j++)
{
if(D[E[i][j].first]!=-1)continue;
length(E[i][j].first,D,E);
}
int max=0;
if(E[i].size()==0){D[i]=0;   return 0;}
int max_ind=0;

for(int j=0;j<E[i].size();j++){

if(max<D[E[i][j].first]){ max_ind=j;
	                  max=D[E[i][j].first];
                          }}

D[i]=max+1;


return 0;

}

void print(int i, vector<int > &D,vector< vector < pair < int,int > > > &E)
{

cout<<i;
int max=0;
int max_ind=-1;

for(int j=0;j<E[i].size();j++)
{
if(max>D[E[i][j].first]){max=D[E[i][j].first];max_ind=E[i][j].first;}
}

if(max_ind==-1)return;
print(max_ind,D,E);


return;
}


main(){


ll N,M;
cin>>N>>M;
vector < vector < pair <int ,int > > > Edge(100005);
for(int i=0;i<M;i++){
	int x,y;
	cin>>x>>y;
	Edge[x-1].push_back(make_pair(y-1,-1));
	
}
vector<int > D(N,-1);


for(int i=0;i<N;i++){
length(i,D,Edge);
}


int max_ind=0;
int max=0;
for(int i=0;i<N;i++)
{
//cout<<i<<D[i]<<"  ";
if(max<D[i]){max=D[i];max_ind=i;}
}

cout<<max;
//print(max_ind,D,Edge);



}


Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
/*ライブラリゾーン！！！！！！！！！！！！！！！*/
int n, a[100005],ans;
map<int, int>mp;
signed main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mp[a[i]]++;
	}
	for (int i = 0; i < n; i++) {
		if (mp[a[i]] % 2) {
			ans++;
			mp[a[i]] = 0;
		}
	}
	cout << ans << endl;
end:;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 7544
#import 
#=input()
n=int(input())
#=map(int,input().split())
a=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
mod = 10 ** 9 + 7

sum = 0
for i in range(n):
    sum += a[i]

s = 0
for i in range(n-1):
    sum -= a[i]
    s = (s + a[i] * sum) % mod
print(s)

Measured memory_bytes: 31676
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long X = nx[1];
        //ちゅーごくじょーよてーり
        //オーダーによってSの終端が決定する
        //まず影響するのは降順のみなことは自明に分かって、
        //で、「次」を選ぶことができる順番は
        //「確率」「期待値」
        //aを取り除いた場合、その後に適用できるのはそれ以前全て。

        List<int> s = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToList();
        ModInt[] dp = new ModInt[X + 1];
        dp[X] = 1;
        int remain = s.Count - 1;
        foreach (var mod in s)
        {
            ModInt[] newDP = new ModInt[X + 1];

            for (int i = 0; i < dp.Length; i++)
            {
                newDP[i % mod] += dp[i];
                newDP[i] += dp[i] * remain;
            }
            remain--;
            dp = newDP;
        }
        ModInt res = 0;
        for (int i = 0; i < dp.Length; i++)
        {
            res += dp[i] * i;
        }
        Console.WriteLine(res);
    }
}


struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ModInt(long data) { Data = data; Eval(); }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private long Eval() => (Data %= MOD) < 0 ? Data += MOD : Data;
    public static implicit operator long(ModInt modInt) => modInt.Eval();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long val) => new ModInt(val);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, ModInt b)
    {
        long res = a.Data + b.Data;
        return new ModInt() { Data = res >= MOD ? res - MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, ModInt b)
    {
        long res = a.Data - b.Data;
        return new ModInt() { Data = res < 0 ? res + MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt a, ModInt b) => new ModInt(a.Data * b.Data);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 31360
#include <stdio.h>
#include <vector>
#include <bitset>
using namespace std;
const int N=5e2+10;
const int C=1e4+10;
const int SC=1e2+10;
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a>b?b:a;}
long long int gcd(long long int a,long long int b){return b==0?a:gcd(b,a%b);}
long long int lcm(long long int a,long long int b){return a/gcd(a,b)*b;}
long long int ans[N][N];
int n;
long long int f(int a,int b){
if(a<0||b<0||a>=n||b>=n)return 1;
else return ans[a][b];
}
int main(){
int tot;
bitset<C> went;
vector<int> prime;
scanf("%d",&n);
if(n==2){
printf("4 7\n23 10\n");
return 0;
}
went.reset();
prime.push_back(2);
for(int i=3;i<SC;i+=2){
if(!went[i]){
prime.push_back(i);
for(int j=i*i;j<C;j+=i<<1)went[j]=true;
}
}
for(int i=SC+1;i<C;i+=2)if(!went[i])prime.push_back(i);
for(int i=0;i<n;i++)for(int j=0;j<n;j++)ans[i][j]=0;
for(int i=0;i<n;i++){
tot=min(i,n-i-1);
for(int j=-tot;j<=tot;j++)ans[i+j][i-j]=prime[i];
}
for(int i=-((n-1)>>1);i<((n+1)>>1);i++){
tot=min(n-i-1,n+i-1);
for(int j=max(i,-i);j<=tot;j++)ans[i+j][j-i]*=prime[i+n+((n-1)>>1)];
}
for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(ans[i][j]==0)ans[i][j]=lcm(lcm(f(i-1,j),f(i,j-1)),lcm(f(i+1,j),f(i,j+1)))+1;
for(int i=0;i<n;i++){
printf("%lld",ans[i][0]);
for(int j=1;j<n;j++)printf(" %lld",ans[i][j]);
printf("\n");
}
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;

ll n,k;
ll a[maxN];
bool check(ll x)
{
	ll cnt = 0;
	for(int i=1;i<=n;i++)
	{
		if(a[i] >= x)
		{
			cnt += ((a[i]/x) - (a[i]%x == 0));
		}
	}
	if(cnt <= k)
	{
		return true;
	}
	else
	{
		return false;
	}
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	ll L = 1,R = 1e9;
	ll ans = R;
	while(L<=R)
	{
		ll mid = (L+R)/2;
		if(check(mid))
		{
			ans = mid;
			R = mid-1;
		}
		else
		{
			L = mid+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5208
#include <iostream>
using namespace std;
     
int main(){
    int a,b;
     
    cin >> a;
    cin >> b;
    
    if(a>b){
     
       cout << "a > b" << endl;
    
    }else if(a<b){
    
       cout << "a < b" << endl;
 
    }else{
 
       cout << "a == b" << endl;   
 
    };
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;
#define int long long

const int NMAX = 2*1e2 + 50; 
int color[NMAX];
int visited[NMAX];
bool adj[NMAX][NMAX];

signed main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i=1; i<=n; i++){
		string s;
		cin >> s;
		for(int j=1; j<=n; j++)
			adj[i][j] = s[j-1]-'0';
	}

	fill(color, color+NMAX, -1);
	queue <pii> q;
	q.push(mp(1,0));
	color[1] = 0;

	while(!q.empty()){
		pii t = q.front();
		q.pop();

		for(int i=1; i<=n; i++){
			if(i == t.fi) continue;
			if(adj[t.fi][i]){
				if(color[i] == -1){
					color[i] = 1-t.sc;
					q.push(mp(i, 1-t.sc));
				}else if(color[i] == color[t.fi]){
					cout << -1;
					return 0;
				}
			}
		}
	}

	int res = 0;
	
	for(int i=1; i<=n; i++){
		queue <pii> q2;
		q2.push(mp(i, 1));
		fill(visited, visited+NMAX, 0);
		visited[i] = 1;
		while(!q2.empty()){
			pii t = q2.front();
			q2.pop();
			res = max(res, t.sc);

			for(int i=1; i<=n; i++){
				if(i == t.fi) continue;
				if(adj[i][t.fi]){
					if(visited[i] != 0){
						continue;
					}
					visited[i] = t.sc+1;
					q2.push(mp(i, t.sc+1));
				}
			}
		}
	
	}
	

	cout << res;

	return 0;
}

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

int main() {
    int inf = 1001001001;
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h.at(i);
    }
    vector<int> dp(n, inf);
    dp.at(0) = 0;
    for (int j = 0; j < n - 2; ++j) {
        dp.at(j + 1) = min(dp.at(j + 1), dp.at(j) + abs(h.at(j) - h.at(j + 1)));
        dp.at(j + 2) = min(dp.at(j + 2), dp.at(j) + abs(h.at(j) - h.at(j + 2)));
    }
    cout << min(dp.at(n - 1), dp.at(n - 2) + abs(h.at(n - 1) - h.at(n - 2))) << endl;
}


Measured memory_bytes: 1024
x1, y1, x2, y2 = map(int, input().split())

vecx = x2 - x1
vecy = y2 - y1

vecx2 = -vecy
vecy2 = vecx

x3 = x2 + vecx2
y3 = y2 + vecy2

x4 = x1 + vecx2
y4 = y1 + vecy2

print(str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4))


Measured memory_bytes: 2940
a,b = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split("")
c = 0
for i in 0..a+b
  if !("0123456789".include?(s[i]))
    c += 1
  end
end
if s[a] == "-" && c == 1
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;}
template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;}

const int maxm = 2000;
ll dp[maxm + 3][maxm + 3];

ll fn(ll l, ll r, ll idx, pair<ll, ll> arr[]) {
  if (l > r) {
    return 0;
  }

  if (dp[l][r] != -1) {
    return dp[l][r];
  }

  ll op1 = arr[idx].first * (abs(arr[idx].second - l)) + fn(l + 1, r, idx + 1, arr);

  ll op2 = arr[idx].first * (abs(arr[idx].second - r)) + fn(l, r - 1, idx + 1, arr);

  dp[l][r] = max(op1, op2);

  return dp[l][r];

}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif



  ll n;
  cin >> n;

  pair<ll, ll> arr[n + 1];

  for (ll i = 1; i <= n; i++) {
    cin >> arr[i].first;
    arr[i].second = i ;
  }

  sort(arr + 1, arr + n + 1, greater<pair<ll, ll>>());

  memset(dp, -1, sizeof(dp));

  cout << fn(1, n, 1, arr) << endl;
}

Measured memory_bytes: 35116
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

#[derive(Eq, PartialEq)]
struct State {
    v: usize,
    d: u64,
}

use std::cmp::Ordering;
impl Ord for State {
    fn cmp(&self, other: &Self) -> Ordering {
        other.d.cmp(&self.d)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(&other))
    }
}

fn dijkstra(src: usize, g: &Vec<Vec<(usize, u32)>>) -> Vec<u64> {
    let inf: u64 = 10000000000000000;
    let mut dp = vec![inf; g.len()];
    dp[src] = 0;
    let mut h = std::collections::BinaryHeap::new();
    h.push(State{v: src, d: 0});
    while let Some(State{v, d}) = h.pop() {
        if d > dp[v] {
            continue;
        }
        for &(u, t) in &g[v] {
            let c = d + t as u64;
            if c < dp[u] {
                dp[u] = c;
                h.push(State{v: u, d: c});
            }
        }
    }
    dp
}

use std::io::BufWriter;
use std::io::Write;

fn run() {
    input! {
        n: usize,
        m: usize,
        s: usize1,
        t: usize1,
        e: [(usize1, usize1, u32, u32); m],
    }
    let mut g = vec![vec![]; n];
    let mut h = vec![vec![]; n];
    for (u, v, a, b) in e {
        g[u].push((v, a));
        g[v].push((u, a));
        h[u].push((v, b));
        h[v].push((u, b));
    }
    let x = dijkstra(s, &g);
    let y = dijkstra(t, &h);
    let mut prev = 0;
    let mut ans = vec![0; n];
    for ((x, y), dp) in x.iter().zip(y.iter()).zip(ans.iter_mut()).rev() {
        let z = 1000000000000000 - (*x + *y);
        prev = std::cmp::max(prev, z);
        *dp = prev;
    }
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    for ans in ans {
        writeln!(out, "{}", ans).unwrap();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 36596
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define fastio                        \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(NULL);
#define pb push_back
#define mp make_pair

using ll  = long long;

using namespace std;
ll x, y, z, l, m, n, r, q, k;

int main()
{
    fastio;
    cin>>n;
    int count = 0; string ans = "No";
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(x==y) count++;

        else count = 0;

        if(count == 3) ans = "Yes";
    }

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

Measured memory_bytes: 3648
import Data.Char
main=mapM_ putStrLn.solve=<<readLn
solve n=map(reverse.fst)$foldr(\_->concatMap f)[("a",'b')][2..n]
f(s,c)=map g['a'..c]where
  g d=(d:s,if d/=c then c else chr$ord c+1)

Measured memory_bytes: 4828
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a[4]={},s[2]={-1,1};
	char op[2]={'-','+'};
	string in;
	cin>>in;
	FOR(i,0,4)a[i]=in[i]-'0';
	FOR(p,0,2){
		FOR(q,0,2){
			FOR(r,0,2){
				int sev=a[0]+a[1]*s[p]+a[2]*s[q]+a[3]*s[r];
				if(sev==7){
					cout<<a[0]<<op[p]<<a[1]<<op[q]<<a[2]<<op[r]<<a[3]<<"=7"<<endl;
					return 0;
				}
			}
		}
	}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define Max 10000
static const int INFTY =(1<<20);
int n;
vector<pair<int,int> > grf[Max];
void dikusutora(void){
  priority_queue<pair<int,int> > AA;
  int col[Max];
  int s[Max];
  int i,t,j,r;
  for(i=0;i<n;i++){
    s[i]=INFTY;
    col[i]=0;
  }
  s[0]=0;
  AA.push(make_pair(0,0));
  col[0]=1;
  while(!AA.empty()){
    pair<int,int> d=AA.top();AA.pop();
    t=d.second;
    col[t]=2;
    if(s[t]<d.first*(-1))continue;
    for(j=0;j<grf[t].size();j++){
      r=grf[t][j].first;
      if(col[r]==2)
        continue;
      if(s[r]>s[t]+grf[t][j].second){
        s[r]=s[t]+grf[t][j].second;
        AA.push(make_pair(s[r]*(-1),r));
        col[r]=1;
      }
    }
  }

  for(i=0;i<n;i++){
    cout<<i<<" "<<(s[i]==INFTY ? -1 : s[i])<<endl;
  }
}
int main(){
  int a,b,c,d;
  int i,j;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a>>b;
    for(j=0;j<b;j++){
      cin>>c>>d;
      grf[a].push_back(make_pair(c,d));
    }
  }
  dikusutora();
  return 0;
}


Measured memory_bytes: 8084
import java.util.Scanner;

public class Main{
    public static void main(String[] ar){
        Scanner sc=new Scanner(System.in);
        for(int i=1;;i++){
            int k=sc.nextInt();
            if(k==0){
                break;
            }
            System.out.println("Case "+i+": "+k);

        }
    }
}


Measured memory_bytes: 41352
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String Sa =sc.next();
        String Sb =sc.next();
        String Sc =sc.next();
        
        String sptA[]=Sa.split("");
        String sptB[]=Sb.split("");
        String sptC[]=Sc.split("");
        
        String ansA=sptA[0].toUpperCase();
        String ansB=sptB[0].toUpperCase();
        String ansC=sptC[0].toUpperCase();
        
        System.out.println(ansA+ansB+ansC);
        
        
   }
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int X;
    cin >> X;
    if(X==3||X==5||X==7) cout << "YES" << endl;
    else cout << "NO" << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> cost(1000000);
vector<vector<int>> data(1000000);


int main(){
    int n, count = 0;
    cin >> n;
    vector<char> c(n);
    stack<int> red;
    for(int i = 0; i < n; i++){
        char x;
        cin >> x;
        if(x == 'R') red.push(i);
        c.at(i) = x;
    }
    for(int i = 0; i < n; i++){
        if(red.empty()) break;
        if(c.at(i) == 'W'){
            c.at(red.top()) = 'W';
            //cout << i << " " << red.top() << endl;
            c.at(i) = 'R';
            red.pop();
            
            count++;
        }
        if(red.empty()) break;
        if(i >= red.top()) break;
    }
    cout << count << endl;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	set<string>t;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
	t.insert(s);	
	}
	cout<<t.size()<<endl;
	return 0;
}

Measured memory_bytes: 19048
#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d%d", &a, &b);
    if(a+b >= a-b && a+b >= a*b) printf("%d\n", a+b);
    else if(a-b >= a+b && a-b >= a*b) printf("%d\n", a-b);
    else if(a*b >= a+b && a*b >= a-b) printf("%d\n", a*b);
    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  map<string, int> a;
  int q;
  cin >> q;
  vector<int> ans;
  rep(i,q) {
    int command; cin >> command;
    if (command == 0) {
      string key;
      int x;
       cin >> key >> x;
      a[key] = x;
    } else if (command == 1) {
      string key; cin >> key;
      ans.push_back(a[key]);
    }
  }

  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 27732
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    
    ll pcnt = 0, gcnt = 0;
    ll point = 0;
    rep(i, s.size()){
        if(pcnt < gcnt){
            if(s[i] == 'g')++point;
            ++pcnt;
        }
        else{
            if(s[i] == 'p')--point;
            ++gcnt;
        }
    }
    cout << point << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int i =0;
  while (i<n){
      string s;
      cin >> s;
      if (s=="Y") {
          cout << "Four" << endl;
          break;
      }
      i++;
  }
  if(i == n){
      cout << "Three" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, A[3], B[3];
ll dp[5000 * 5000 + 1];
ll v[3], w[3];

ll solve(){
    REP(i, 3) v[i] = B[i], w[i] = A[i];
    REP(i, 3){
        REP(j, N + 1){
            if(j - w[i] >= 0) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    ll M = 0;
    REP(j, N + 1) M = max(M, N - j + dp[j]);
    REP(j, N + 1) dp[j] = 0;
    REP(i, 3) v[i] = A[i], w[i] = B[i];
    REP(i, 3){
        REP(j, M + 1){
            if(j - w[i] >= 0) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    ll ret = 0;
    REP(j, M + 1) ret = max(ret, M - j + dp[j]);
    return ret;
}

signed main(){
    cin >> N;
    REP(i, 3) cin >> A[i];
    REP(i, 3) cin >> B[i];
    PRINT(solve());
    return 0;
}

Measured memory_bytes: 198716
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);

		int N = int.Parse(Console.ReadLine());
		var A = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
		int[] x = new int[N];
		x[0] = 0;
		for (var i = 0; i < N; i++)
		{
			if (i % 2 == 0) { x[0] += A[i]; }
			else { x[0] -= A[i]; }
		}
		for (var i = 1; i < N; i++)
		{
			x[i] = 2 * A[i - 1] - x[i - 1];
		}
		for (var i = 0; i < N; i++)
		{
			Console.Write(x[i] + " ");
		}
	


	 Console.Out.Flush();
	}
}

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

int main() {
  double N, T, A;
  cin >> N >> T >> A;
  
  vector<double> H(N);
  double kion = 10000;
  double basho;
  for( int i = 0; i < N; i++ ){
    cin >> H.at(i);
    H.at(i) = T - ( H.at(i) * 0.006 );
    if( kion > abs( A - H.at(i) ) ){
      kion = abs( A - H.at(i) );
      basho = i+1;
    }
  }
  cout << basho << endl;
  
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define RMAX 4294967295
#define equals(a,b)(fabs((a)-(b))<EPS)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef complex<double> comp;
typedef vector<complex<double>> vcomp;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef string::const_iterator State;
class ParseError {};
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;



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

	int N;
	cin >> N;
	if (N % 10 == 9 || N / 10 == 9)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
ll n;
void solve(){
	cin>>n;
	cout<<a[n-1];
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
 
int selectionSort(int A[], int N) {
    int i, j, t, sw = 0, minj;
    for (i = 0; i < N - 1; i++) {
        minj = i;
        for (j = i; j < N; j++) {
            if (A[j] < A[minj])minj = j;
        }
        t = A[i]; A[i] = A[minj]; A[minj] = t;
        if (i != minj)sw++;
    }
    return sw;
}
 
int main() {
    int A[100], N, i, sw;
 
    scanf("%d", &N);
    for (i = 0; i < N; i++)scanf("%d", &A[i]);
 
    sw = selectionSort(A, N);
 
    for (i = 0; i < N; i++) {
        if (i > 0)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);
 
    return 0;
}

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

int maxRate(int* R, int N) {
	int minv = R[0];
	int maxv = R[1]-R[0];
	for (int j = 1; j < N; j++) {
		if (maxv < R[j] - minv)
			maxv = R[j] - minv;
		else if (minv > R[j])
			minv = R[j];
	}
	return maxv;
}

int main() {
	int N;
	cin >> N;
	int* R = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> R[i];
	}
	int max = maxRate(R, N);
	cout << max << endl;
}



Measured memory_bytes: 3864
n,k=[int(j) for j in input().split()]
s=input()
l=[1]
for i in range(1,n):
    if s[i]==s[i-1]:
        l[-1]+=1
    else:
        l.append(1)
if len(l)//2<=k:
    print(n-1)
    exit()
ans=sum(l)-len(l)
ans+=2*k
print(ans)


Measured memory_bytes: 3956
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] pri = new int[1000002];
		for(int i=2;i<=1000000;i++){
			pri[i] = i;
		}
		for(int i=2;i<=1000000;i++){
			for(int j=i+i;j<=1000000;j+=i){
					pri[j]=0;
			}
		}

		while(true){
			int a = sc.nextInt();
			int d = sc.nextInt();
			int n = sc.nextInt();
			if((a|d|n)==0)break;
			int count = 0;
			int i=a;
			while(true){
				if(pri[i]>0)count++;
				if(count==n){
					System.out.println(i);
					break;
				}
				i += d;
			}
			
		}
	}
	
}

Measured memory_bytes: 25596
from collections import Counter
s = list(input())
t = list(input())

s_count = Counter(s)
t_count = Counter(t)

# s,tそれぞれの各文字の出現回数が同じであれば一致させられる
if sorted(s_count.values()) == sorted(t_count.values()): print("Yes")
else: print("No")

Measured memory_bytes: 12576
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define all(c) (c).begin(),(c).end()

using namespace std;

int main(void){

  string s;
  cin >> s;
  int n=s.size();
  vector<int>J(n),O(n),I(n);

  fill(all(J),0);
  fill(all(O),0);
  fill(all(I),0);
  
  if(s[0]=='J')J[0]=1;
  if(s[0]=='O')O[0]=1;
  if(s[0]=='I')I[0]=1;

  for(int i=1;i<n;i++){
    if(s[i]=='J')J[i]=J[i-1]+1;
    if(s[i]=='O')O[i]=O[i-1]+1;
    if(s[i]=='I')I[i]=I[i-1]+1;
  }
  
  int ans=0;
  for(int i=0;i<n;i++){
    if(i-I[i]-O[i-I[i]]<0)continue;
    if(I[i]>=O[i-I[i]] && O[i-I[i]]<=J[i-I[i]-O[i-I[i]]])
      ans=max(ans,min(I[i],min(J[i-I[i]-O[i-I[i]]],O[i-I[i]])));
  }

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

Measured memory_bytes: 13984
import java.io.*;
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
      Scanner sc=new Scanner(System.in);
       while(true){
        String  x=sc.next();
        if(x.equals("0"))break;
        int  sum=0;
        for(int i=0;i<x.length();i++){
               sum+=Character.getNumericValue(x.charAt(i));
           }
        System.out.println(sum);
      }
    }
}


Measured memory_bytes: 26244
A = int(input())
B = int(input())
C = int(input())
X = int(input())

A = min(A, X // A) if A > 0 else 0
B = min(B, X // B) if B > 0 else 0
C = min(C, X // C) if C > 0 else 0
cnt = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                cnt += 1
print(cnt)


Measured memory_bytes: 9144